Skip to content

feat: add a hand-written Prometheus label values method - #77

Merged
ysyneu merged 2 commits into
mainfrom
feat/prometheus-label-values
Sep 14, 2026
Merged

ysyneu merged 2 commits into
mainfrom
feat/prometheus-label-values

Conversation

@ysyneu

@ysyneu ysyneu commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

GET /monit/prometheus/api/v1/label/{label_name}/values has a path parameter, so the generator skips it and it never got a typed method. This adds DataSourcesService.ReadPrometheusLabelValues(ctx, dataSourceID, labelName) by hand.

  • Sends the data source id in the X-DSID header and path-escapes the label name.
  • The endpoint proxies the data source's native Prometheus payload without the Flashduty {request_id, error, data} envelope. A 2xx body is decoded straight into the generated PrometheusLabelValuesResponse.
  • A non-2xx body is either plain text from the platform or the data source's own JSON error, so its raw text becomes the returned error's Message instead of being parsed as a Flashduty error.
  • The base commit also syncs the vendored OpenAPI spec and regenerates code.

Tests

  • data_sources_prometheus_test.go covers path escaping, the header and app key, decoding, and the non-enveloped error path.
  • go build ./..., go vet ./... and go test -race ./... pass.

The generator skips this operation because it has a path parameter, so
it never gets a typed client method. Add one by hand: GET the label's
values through the Monitors proxy with the X-DSID header, and decode
straight into the generated PrometheusLabelValuesResponse rather than
through the Flashduty envelope, since the endpoint returns the data
source's native Prometheus payload unwrapped.
@ysyneu
ysyneu merged commit d3fc668 into main Sep 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant