Skip to content

Commit 2bad70b

Browse files
committed
readme.
1 parent 5ef2ee9 commit 2bad70b

File tree

3 files changed

+75
-8
lines changed

3 files changed

+75
-8
lines changed

qcloud_exporter.go

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package main
2+
3+
import (
4+
"net/http"
5+
6+
"github.com/tencentyun/tencentcloud-exporter/collector"
7+
"github.com/tencentyun/tencentcloud-exporter/config"
8+
"github.com/tencentyun/tencentcloud-exporter/instances"
9+
"github.com/tencentyun/tencentcloud-exporter/monitor"
10+
11+
"github.com/prometheus/client_golang/prometheus"
12+
"github.com/prometheus/client_golang/prometheus/promhttp"
13+
"github.com/prometheus/common/log"
14+
"github.com/prometheus/common/version"
15+
kingpin "gopkg.in/alecthomas/kingpin.v2"
16+
)
17+
18+
func main() {
19+
20+
var (
21+
listenAddress = kingpin.Flag("web.listen-address", "Address on which to expose metrics and web interface.").
22+
Default("localhost:8001").String()
23+
24+
metricsPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").
25+
Default("/metrics").String()
26+
27+
configFile = kingpin.Flag("config.file", "Tencent qcloud exporter configuration file.").
28+
Default("qcloud.yml").String()
29+
)
30+
log.AddFlags(kingpin.CommandLine)
31+
kingpin.Version(version.Print("tencent_qcloud_exporter"))
32+
kingpin.HelpFlag.Short('h')
33+
kingpin.Parse()
34+
35+
log.Infoln("Starting tencent_qcloud_exporter", version.Info())
36+
log.Infoln("Build context", version.BuildContext())
37+
38+
tencentConfig := config.NewConfig()
39+
if err := tencentConfig.LoadFile(*configFile); err != nil {
40+
log.Fatal(err.Error())
41+
}
42+
43+
credentialConfig := (*tencentConfig).Credential
44+
metricsConfig := (*tencentConfig).Metrics
45+
46+
if err := monitor.InitClient(credentialConfig, (*tencentConfig).RateLimit); err != nil {
47+
log.Fatal(err.Error())
48+
}
49+
50+
if err := instances.InitClient(credentialConfig); err != nil {
51+
log.Fatal(err.Error())
52+
}
53+
54+
tencentCollector, err := collector.NewCollector(metricsConfig)
55+
if err != nil {
56+
log.Fatal(err.Error())
57+
}
58+
59+
registry := prometheus.NewRegistry()
60+
registry.MustRegister(tencentCollector)
61+
62+
http.Handle(*metricsPath, promhttp.HandlerFor(registry, promhttp.HandlerOpts{}))
63+
64+
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
65+
w.Write([]byte(`<html>
66+
<head><title>TencentCloud Exporter</title></head>
67+
<body>
68+
<h1>TencentCloud Exporter</h1>
69+
<p><a href='` + *metricsPath + `'>Metrics</a></p>
70+
</body>
71+
</html>`))
72+
})
73+
74+
log.Fatal(http.ListenAndServe(*listenAddress, nil))
75+
}

readme.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,9 @@ eg:
238238

239239
可用维度
240240

241-
242241
- [appid,bucket]
243242

244243
eg:
245-
246244
```
247245
- tc_namespace: guauga/cos
248246
tc_metric_name: StdWriteRequests
@@ -254,7 +252,6 @@ eg:
254252
delay_seconds: 300
255253
range_seconds: 60
256254
```
257-
258255
### **专线(逻辑层-专线通道):dcx** (tc_labels风格)
259256

260257

@@ -264,7 +261,6 @@ eg:
264261
{"DirectConnectTunnelId","DirectConnectTunnelName","VpcId","TencentAddress","CustomerAddress"}
265262
```
266263
eg:
267-
268264
```
269265
- tc_namespace: Tencent/dcx
270266
tc_metric_name: Delay
@@ -275,12 +271,10 @@ eg:
275271
range_seconds: 600
276272
```
277273
### **专线(物理层-物理通道):dc** (tc_labels风格)
278-
279274
```
280275
{"DirectConnectId","DirectConnectName"}
281276
```
282277
eg:
283-
284278
```
285279
- tc_namespace: Tencent/dc
286280
tc_metric_name: Outbandwidth
@@ -293,12 +287,10 @@ eg:
293287

294288

295289
### **NAT 网关:nat** (tc_labels风格)
296-
297290
```
298291
{"InstanceId","InstanceName", "Zone"}
299292
```
300293
eg:
301-
302294
```
303295
- tc_namespace: test/nat
304296
tc_metric_name: Outbandwidth

tencentcloud-exporter.exe

-20.5 MB
Binary file not shown.

0 commit comments

Comments
 (0)