Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Add filtering on server status #160

Merged
merged 2 commits into from Jun 2, 2020
Merged

Conversation

mhyllander
Copy link
Contributor

Allow excluding metrics for server slots depending on their status. Using
this you can avoid reporting metrics for unused server slots when using
dynamic scaling in haproxy.

E.g. you can use

--haproxy.server-exclude-states='DOWN,MAINT,MAINT (resolution)'

@SuperQ
Copy link
Member

SuperQ commented May 19, 2020

Interesting, would you mind rebasing this against the current master?

Allow excluding metrics for server slots depending on their status. Using
this you can avoid reporting metrics for unused server slots when using
dynamic scaling in haproxy.

E.g. you can use

  --haproxy.server-exclude-states='DOWN,MAINT,MAINT (resolution)'

Signed-off-by: Magnus Hyllander <magnus.hyllander@hivestreaming.com>
@mhyllander
Copy link
Contributor Author

Rebased on master

@SuperQ
Copy link
Member

SuperQ commented May 28, 2020

quay.io is having problems today. ☹️

Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@grobie grobie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! I think we can keep the original interface of the Exporter and NewExporter() and do the filtering before, as we already have similar functionality. This will also avoid the changes to the test file as the interface stays the same.

A test for the filter function would be nice as well.

haproxy_exporter.go Show resolved Hide resolved
return 1
case "DOWN", "DOWN 1/2", "NOLB", "MAINT":
default: //case "DOWN", "DOWN 1/2", "NOLB", "MAINT", "MAINT(via)", "MAINT(resolution)":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already return 0 / down as a fallback. What's the motivation for this change instead of listing known down status explicitly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure what to do with this function, since I haven't found a complete list of possible server statuses. I considered extending the list with the statuses I knew about, but decided there was no point, especially since (as you say) the fallback was 0 / down anyway. I guess I could have done it in a nicer way, letting it fall through to the fallback instead.

}

for field, metric := range serverMetrics {
if _, ok := selected[field]; ok {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup! 🎉

@SuperQ SuperQ mentioned this pull request Jun 1, 2020
Copy link
Member

@grobie grobie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your contribution! If you have time, adding a test would be great to ensure this requested feature survives changes over time. I'll resolve the merge conflicts and merge for now to not block this even longer.

@grobie grobie merged commit 8205efb into prometheus:master Jun 2, 2020
@SuperQ SuperQ mentioned this pull request Jun 17, 2020
grobie added a commit that referenced this pull request Jun 21, 2020
* [CHANGE] Switch logging to go-kit #171
* [CHANGE] Fix metric types #182
* [CHANGE] Fix unit of time metric #183
* [FEATURE] Add filtering on server status #160
* [ENHANCEMENT] Add compression and server selection metrics #154
* [ENHANCEMENT] Add client/server abort metrics #167
* [ENHANCEMENT] Add version info metric (when using UNIX sockets) #180

Note: This release fixes the metric types of counters and renames the following metrics:

* `haproxy_exporter_csv_parse_failures` -> `haproxy_exporter_csv_parse_failures_total`
* `haproxy_exporter_total_scrapes` -> `haproxy_exporter_scrapes_total`
* `haproxy_server_check_duration_milliseconds` -> `haproxy_server_check_duration_seconds`

Signed-off-by: Tobias Schmidt <tobidt@gmail.com>
grobie added a commit that referenced this pull request Jun 21, 2020
* [CHANGE] Switch logging to go-kit #171
* [CHANGE] Fix metric types #182
* [CHANGE] Fix unit of time metric #183
* [FEATURE] Add filtering on server status #160
* [ENHANCEMENT] Add compression and server selection metrics #154
* [ENHANCEMENT] Add client/server abort metrics #167
* [ENHANCEMENT] Add version info metric (when using UNIX sockets) #180

Note: This release fixes the metric types of counters and renames the following metrics:

* `haproxy_exporter_csv_parse_failures` -> `haproxy_exporter_csv_parse_failures_total`
* `haproxy_exporter_total_scrapes` -> `haproxy_exporter_scrapes_total`
* `haproxy_server_check_duration_milliseconds` -> `haproxy_server_check_duration_seconds`

Signed-off-by: Tobias Schmidt <tobidt@gmail.com>

Co-authored-by: Tobias Schmidt <tobidt@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants