Skip to content

Commit

Permalink
prometheus plugin: support get scrape urls from consul
Browse files Browse the repository at this point in the history
  • Loading branch information
UlricQin committed Jun 9, 2022
1 parent cf9de96 commit e2640c0
Show file tree
Hide file tree
Showing 6 changed files with 342 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
.vscode
/categraf*
*.log
vendor
/vendor
15 changes: 14 additions & 1 deletion conf/input.prometheus/prometheus.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
# # collect interval
# interval = 15

# [[instances]]
[[instances]]
# urls = [
# "http://localhost:9104/metrics"
# ]

## Scrape Services available in Consul Catalog
[instances.consul]
enabled = false
agent = "http://localhost:8500"
query_interval = "5m"

[[instances.consul.query]]
name = "a service name"
tag = "a service tag"
url = 'http://{{if ne .ServiceAddress ""}}{{.ServiceAddress}}{{else}}{{.Address}}{{end}}:{{.ServicePort}}/{{with .ServiceMeta.metrics_path}}{{.}}{{else}}metrics{{end}}'
[instances.consul.query.tags]
host = "{{.Node}}"

# bearer_token_string = ""

# e.g. /run/secrets/kubernetes.io/serviceaccount/token
Expand Down
13 changes: 13 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.5.2
github.com/golang/snappy v0.0.4
github.com/hashicorp/consul/api v1.13.0
github.com/influxdata/line-protocol/v2 v2.2.1
github.com/jmoiron/sqlx v1.3.5
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
Expand All @@ -38,13 +39,15 @@ require (
github.com/BurntSushi/toml v1.1.0 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/alouca/gologger v0.0.0-20120904114645-7d4b7291de9c // indirect
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/fatih/camelcase v1.0.0 // indirect
github.com/fatih/color v1.9.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/freedomkk-qfeng/go-fastping v0.0.0-20160109021039-d7bb493dee3e // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
Expand All @@ -53,7 +56,17 @@ require (
github.com/godror/knownpb v0.1.0 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/hashicorp/go-hclog v0.12.0 // indirect
github.com/hashicorp/go-immutable-radix v1.0.0 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.5.1 // indirect
github.com/hashicorp/serf v0.9.6 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
Expand Down
Loading

0 comments on commit e2640c0

Please sign in to comment.