Skip to content

Commit

Permalink
del username and password
Browse files Browse the repository at this point in the history
  • Loading branch information
lts120784620 committed Jun 16, 2020
1 parent f951e14 commit d3de7a5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ Prometheus-collector以插件形式集成在collector中,通过Nightingale插
exporter_urls | array | Address to collect metric for prometheus exporter.
append_tags | array | Add tags for n9e metric default empty
endpoint | string | Field endpoint for n9e metric default empty
username | string | Not needed for now
password | string | Not needed for now
ignore_metrics_prefix | array | Ignore metric prefix default empty
timeout | int | Timeout for access a exporter url default 500ms
###
=======

###
29 changes: 21 additions & 8 deletions collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import (
)

const validConfigParam = `{
"exporter_urls":["http://127.0.0.1:9104/metrics?dns=xxip:3306"],
"exporter_urls":["http://127.0.0.1:8080/metrics"],
"append_tags": ["region=bj", "dept=cloud"],
"endpoint": "127.0.0.1",
"username": "xxx",
"password": "xxx",
"ignore_metrics_prefix": ["go_"],
"ignore_metrics_prefix": [],
"timeout": 500
}
`
Expand Down Expand Up @@ -75,7 +73,7 @@ func TestPromMetricParser(t *testing.T) {

metrics, err := collector.Parse([]byte(validPromUntypedMetric))
assert.NoError(t, err)
assert.Len(t, metrics, 0)
assert.Len(t, metrics, 1)

metrics, err = collector.Parse([]byte(validPromGaugeMetric))
assert.NoError(t, err)
Expand All @@ -101,8 +99,6 @@ const validStdin = `{
],
"endpoint": "xxxx",
"append_tags": ["region=bj", "dept=cloud"],
"username": "xxx",
"password": "xxx",
"ignore_metrics_prefix": ["gc_","go_"],
"timeout": 500
}
Expand All @@ -127,6 +123,23 @@ func TestStdout(t *testing.T) {
printMetrics(metrics)
}

func TestGather(t *testing.T) {
err := config.Parse([]byte(validConfigParam))
assert.NoError(t, err)

metrics := collector.Gather()
assert.NotNil(t, metrics)
printMetrics(metrics)
}

const validIgnoreConfigParam = `{
"exporter_urls":["http://127.0.0.1:8080/metrics"],
"append_tags": ["region=bj", "dept=cloud"],
"endpoint": "127.0.0.1",
"ignore_metrics_prefix": ["go_"],
"timeout": 500
}
`
const validPromIgnoreMetric = `# HELP go_gc_duration_seconds A summary of the GC invocation durations.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 1.2099e-05
Expand All @@ -139,7 +152,7 @@ go_gc_duration_seconds_count 84408
`

func TestIgnoreMetric(t *testing.T) {
err := config.Parse([]byte(validConfigParam))
err := config.Parse([]byte(validIgnoreConfigParam))
assert.NoError(t, err)

config.Config.IgnoreMetricsPrefix = []string{"mem"}
Expand Down
4 changes: 0 additions & 4 deletions config/plugin_cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ type PluginCfg struct {
ExporterUrls []string `json:"exporter_urls,omitempty"`
AppendTags []string `json:"append_tags"`
Endpoint string `json:"endpoint"`
Username string `json:"username"`
Password string `json:"password"`
Timeout int `json:"timeout"`
IgnoreMetricsPrefix []string `json:"ignore_metrics_prefix"`
}
Expand All @@ -30,8 +28,6 @@ func Parse(bs []byte) error {
ExporterUrls: []string{},
AppendTags: []string{},
Endpoint: "",
Username: "",
Password: "",
Timeout: 500,
IgnoreMetricsPrefix: []string{},
}
Expand Down
2 changes: 0 additions & 2 deletions plugin.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
],
"append_tags": ["region=bj", "dept=cloud"],
"endpoint": "127.0.0.1",
"username": "",
"password": "",
"ignore_metrics_prefix": ["go_"],
"timeout": 500
}

0 comments on commit d3de7a5

Please sign in to comment.