Skip to content

Commit

Permalink
fixed authorization header and readme edits
Browse files Browse the repository at this point in the history
  • Loading branch information
portertech committed Feb 7, 2018
1 parent 04c8c1d commit 0b5f382
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,23 @@ Help:

```
$ sensu-prometheus-collector -h
Usage of sensu-prometheus-collector:
Usage of ./sensu-prometheus-collector:
-exporter-authorization string
Prometheus exporter Authorization header.
-exporter-password string
Prometheus exporter basic auth password
Prometheus exporter basic auth password.
-exporter-url string
Prometheus exporter URL to pull metrics from.
Prometheus exporter URL to pull metrics from.
-exporter-user string
Prometheus exporter basic auth user
Prometheus exporter basic auth user.
-metric-prefix string
Metric name prefix, only supported by line protocol output formats.
Metric name prefix, only supported by line protocol output formats.
-output-format string
The check output format to use for metrics {influx|graphite|json}. (default "influx")
The check output format to use for metrics {influx|graphite|json}. (default "influx")
-prom-query string
Prometheus API query string. (default "up")
Prometheus API query string. (default "up")
-prom-url string
Prometheus API URL. (default "http://localhost:9090")
Prometheus API URL. (default "http://localhost:9090")
```

Application instrumentation:
Expand Down
14 changes: 7 additions & 7 deletions sensu-prometheus-collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ const (
exporterAuthID = "exporter"
)

type ExporterAuth struct {
User string `envconfig:"user" default:""`
Password string `envconfig:"password" default:""`
Header string `envconfig:"header" default:""`
}

type Tag struct {
Name model.LabelName
Value model.LabelValue
Expand All @@ -31,12 +37,6 @@ type Metric struct {
Value float64
}

type ExporterAuth struct {
User string `envconfig:"user" default:""`
Password string `envconfig:"password" default:""`
Header string `envconfig:"header" default:""`
}

func CreateJSONMetrics(samples model.Vector) string {
metrics := []Metric{}

Expand Down Expand Up @@ -210,7 +210,7 @@ func setExporterAuth(user string, password string, header string) (auth Exporter
auth.Password = password
}

if auth.Header != "" {
if header != "" {
auth.Header = header
}

Expand Down

0 comments on commit 0b5f382

Please sign in to comment.