Skip to content

Commit

Permalink
readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
Himer committed Jul 5, 2019
1 parent 5ef2ee9 commit 2bad70b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 8 deletions.
75 changes: 75 additions & 0 deletions qcloud_exporter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package main

import (
"net/http"

"github.com/tencentyun/tencentcloud-exporter/collector"
"github.com/tencentyun/tencentcloud-exporter/config"
"github.com/tencentyun/tencentcloud-exporter/instances"
"github.com/tencentyun/tencentcloud-exporter/monitor"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/log"
"github.com/prometheus/common/version"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)

func main() {

var (
listenAddress = kingpin.Flag("web.listen-address", "Address on which to expose metrics and web interface.").
Default("localhost:8001").String()

metricsPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").
Default("/metrics").String()

configFile = kingpin.Flag("config.file", "Tencent qcloud exporter configuration file.").
Default("qcloud.yml").String()
)
log.AddFlags(kingpin.CommandLine)
kingpin.Version(version.Print("tencent_qcloud_exporter"))
kingpin.HelpFlag.Short('h')
kingpin.Parse()

log.Infoln("Starting tencent_qcloud_exporter", version.Info())
log.Infoln("Build context", version.BuildContext())

tencentConfig := config.NewConfig()
if err := tencentConfig.LoadFile(*configFile); err != nil {
log.Fatal(err.Error())
}

credentialConfig := (*tencentConfig).Credential
metricsConfig := (*tencentConfig).Metrics

if err := monitor.InitClient(credentialConfig, (*tencentConfig).RateLimit); err != nil {
log.Fatal(err.Error())
}

if err := instances.InitClient(credentialConfig); err != nil {
log.Fatal(err.Error())
}

tencentCollector, err := collector.NewCollector(metricsConfig)
if err != nil {
log.Fatal(err.Error())
}

registry := prometheus.NewRegistry()
registry.MustRegister(tencentCollector)

http.Handle(*metricsPath, promhttp.HandlerFor(registry, promhttp.HandlerOpts{}))

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<html>
<head><title>TencentCloud Exporter</title></head>
<body>
<h1>TencentCloud Exporter</h1>
<p><a href='` + *metricsPath + `'>Metrics</a></p>
</body>
</html>`))
})

log.Fatal(http.ListenAndServe(*listenAddress, nil))
}
8 changes: 0 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,9 @@ eg:

可用维度


- [appid,bucket]

eg:

```
- tc_namespace: guauga/cos
tc_metric_name: StdWriteRequests
Expand All @@ -254,7 +252,6 @@ eg:
delay_seconds: 300
range_seconds: 60
```

### **专线(逻辑层-专线通道):dcx** (tc_labels风格)


Expand All @@ -264,7 +261,6 @@ eg:
{"DirectConnectTunnelId","DirectConnectTunnelName","VpcId","TencentAddress","CustomerAddress"}
```
eg:

```
- tc_namespace: Tencent/dcx
tc_metric_name: Delay
Expand All @@ -275,12 +271,10 @@ eg:
range_seconds: 600
```
### **专线(物理层-物理通道):dc** (tc_labels风格)

```
{"DirectConnectId","DirectConnectName"}
```
eg:

```
- tc_namespace: Tencent/dc
tc_metric_name: Outbandwidth
Expand All @@ -293,12 +287,10 @@ eg:


### **NAT 网关:nat** (tc_labels风格)

```
{"InstanceId","InstanceName", "Zone"}
```
eg:

```
- tc_namespace: test/nat
tc_metric_name: Outbandwidth
Expand Down
Binary file removed tencentcloud-exporter.exe
Binary file not shown.

0 comments on commit 2bad70b

Please sign in to comment.