-
Notifications
You must be signed in to change notification settings - Fork 9.6k
feat(stackit): postgres flex service discovery #16771
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
base: main
Are you sure you want to change the base?
feat(stackit): postgres flex service discovery #16771
Conversation
3eb548d
to
021ec78
Compare
Signed-off-by: Mauritz Uphoff <mauritz.uphoff@stackit.cloud>
021ec78
to
9f18427
Compare
MAINTAINERS.md
Outdated
@@ -11,7 +11,7 @@ Maintainers for specific parts of the codebase: | |||
* `discovery` | |||
* `azure`: Jan-Otto Kröpke (<mail@jkroepke.de> / @jkroepke) | |||
* `k8s`: Frederic Branczyk (<fbranczyk@gmail.com> / @brancz) | |||
* `stackit`: Jan-Otto Kröpke (<mail@jkroepke.de> / @jkroepke) | |||
* `stackit`: Jan-Otto Kröpke (<mail@jkroepke.de> / @jkroepke), Mauritz Uphoff (<mauritz.uphoff@stackit.cloud> / @h3adex) |
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.
not sure, if external maintaners are fine?
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.
Removed my mail
discovery/stackit/mock_test.go
Outdated
reqBody, err := io.ReadAll(r.Body) | ||
if err != nil { | ||
w.WriteHeader(http.StatusInternalServerError) | ||
_, _ = fmt.Fprint(w, err) | ||
return | ||
} | ||
|
||
// Expecting HTTP form encoded body with the field assertion. | ||
// JWT always start with "ey" (base64url encoded). | ||
if !bytes.HasPrefix(reqBody, []byte("assertion=ey")) { |
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 are requested in an earlier PR, they should not be removed.
stackitLabelPostgresFlexID = stackitLabelPrefix + "postgres_flex_id" | ||
stackitLabelPostgresFlexName = stackitLabelPrefix + "postgres_flex_name" | ||
stackitLabelPostgresFlexStatus = stackitLabelPrefix + "postgres_flex_status" | ||
stackitLabelPostgresFlexRegion = stackitLabelPrefix + "postgres_flex_region" |
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.
Please check, if the exists labels can be re-used. (I guess yes)
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.
I'm not entirely sure I understand your point. Could you please elaborate a bit more?
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.
prometheus/discovery/stackit/stackit.go
Lines 34 to 43 in c3276ea
const ( | |
stackitLabelPrefix = model.MetaLabelPrefix + "stackit_" | |
stackitLabelProject = stackitLabelPrefix + "project" | |
stackitLabelID = stackitLabelPrefix + "id" | |
stackitLabelName = stackitLabelPrefix + "name" | |
stackitLabelStatus = stackitLabelPrefix + "status" | |
stackitLabelPowerStatus = stackitLabelPrefix + "power_status" | |
stackitLabelAvailabilityZone = stackitLabelPrefix + "availability_zone" | |
stackitLabelPublicIPv4 = stackitLabelPrefix + "public_ipv4" | |
) |
I tried to ask, if the existing labels can be used (without role prefix) instead define new labels for each role.
ref: #16401 (comment)
docs/configuration/configuration.md
Outdated
|
||
The postgres_flex role dynamically discovers scrape targets using the [PostgresFlex API](https://docs.api.eu01.stackit.cloud/documentation/postgres-flex-service/version/v2#tag/instance). | ||
|
||
To enable this scrape configuration, a valid Authorization Bearer Token must be provided. Refer to [this example configuration](../../documentation/examples/prometheus-stackit.yml) for guidance. |
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.
A good hint would be useful here that the recommended STACKIT Service Account Key is not supported here.
docs/configuration/configuration.md
Outdated
See below for the configuration options for STACKIT discovery: | ||
|
||
```yaml | ||
# The STACKIT project | ||
project: <string> | ||
|
||
# STACKIT role of entities that should be discovered. | ||
# postgres_flex and server are supported. | ||
[ role : <string> ] |
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.
[ role : <string> ] | |
role : <string> |
If role is required, the brackets should be omit.
Signed-off-by: Mauritz Uphoff <mauritz.uphoff@stackit.cloud>
This PR adds support for monitoring managed Postgres databases by leveraging our Postgres API for automatic service discovery. It introduces a role-based configuration, allowing Prometheus to distinguish between
server
andpostgres_flex
instances. This is a foundational change for future support of additional managed services, such asmongodb_flex
, which I plan to add in a follow-up PR. The change introduces a breaking update: specifying arole
is now required. Previously, only IaaS resources were supported and no explicit role was needed. Since this feature has not yet been released, I believe it’s acceptable to introduce this change now. Alternatively, we could setserver
as the default role to preserve compatibility—happy to adjust based on feedback.Screenshots from my local E2E Tests


My Test setup: