-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor the complete code #49
Refactor the complete code #49
Conversation
915489f
to
4ea7ef2
Compare
* Make the working of this exporter similar to that of the blackbox_exporter to allow probing multiple targets. * Add functionality to add headers to the request * Update the example config to use `headers` as well as the `metrics` keys in alignment with the new code * Add default header 'Accept: application/json' Signed-off-by: rustyclock <[email protected]>
4ea7ef2
to
c869516
Compare
It would be useful to add a Prometheus config example with the required relabeling to the README. |
Signed-off-by: rustyclock <[email protected]>
Signed-off-by: rustyclock <[email protected]>
Signed-off-by: rustyclock <[email protected]>
Migrated to |
Good question, I'm not very opinionated on how the logger is supposed to be used. Maybe @roidelapluie has some opinions? |
Global - no, but you could create a struct that implements Collector and attach the functions to it - and use it from there |
Signed-off-by: rustyclock <[email protected]>
Signed-off-by: rustyclock <[email protected]>
Signed-off-by: rustyclock <[email protected]>
Closes #33 |
Signed-off-by: rustyclock <[email protected]>
Signed-off-by: rustyclock <[email protected]>
cfb0e53
to
a6b9654
Compare
Signed-off-by: rustyclock <[email protected]>
Addresses #44 also, since I added some unit tests now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Ping @roidelapluie, would you mind reviewing this? |
Can we use another package name that internal as it prevents reuse of the code elsewhere? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments :) Awesome work
examples/prometheus.yml
Outdated
relabel_configs: | ||
- source_labels: [__param_target] | ||
target_label: endpoint | ||
action: replace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An exemples à la blackbox_exporter might be better? With the json as target
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I didn't understand this fully I think.
Current example set up:
prometheus
-> scrapes json_exporter
-> fetches localhost:8000/examples/data.json
Proposed example set up:
prometheus
-> scrapes blackbox_exporter
-> probes json_exporter
? -> fetches localhost:8000/examples/data.json
?
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's more about how you use Prometheus configs.
...
static_configs:
- targets:
- http://host-1:8000/examples/data.json
- http://host-2:8000/other-examples/data.json
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 127.0.0.1:7979 # The json exporter's real hostname:port.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification, I have updated the example prometheus config. Let me know if the updated one looks good.
Signed-off-by: rustyclock <[email protected]>
Signed-off-by: rustyclock <[email protected]>
Thanks for the awesome review @roidelapluie. I have made the requested changes and addressed the remaining. |
Signed-off-by: rustyclock <[email protected]>
Ping @SuperQ @roidelapluie Can this be merged if all looks good now? |
Thanks!! |
@rustycl0ck Anything else we should do before we cut a new release? |
@SuperQ Nothing more yet. Thanks 👍 |
After prometheus-community#49 was merged to master the build failed due to a linting error: GO111MODULE=on /go/bin/golangci-lint run ./... exporter/util.go:162:10: Error return value of `io.Copy` is not checked (errcheck) io.Copy(ioutil.Discard, resp.Body) ^ make: *** [Makefile.common:192: common-lint] Error 1 build failure here: https://app.circleci.com/pipelines/github/prometheus-community/json_exporter/28/workflows/e2c53db3-d3a3-4faa-a5a6-3b1fbb5754a0/jobs/71 Signed-off-by: Konstantinos Koukopoulos <[email protected]>
headers
as well as themetrics
keys in alignment with the new codeCloses #43 #30 #14