-
Notifications
You must be signed in to change notification settings - Fork 56
Add custom JSON marshaller for Alertmanager configurations #349
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
Conversation
b8c96ca
to
38ba2fd
Compare
e06b9d6
to
e868977
Compare
} | ||
|
||
func newPlainAPI() jsoniter.API { | ||
api := jsoniter.ConfigCompatibleWithStandardLibrary |
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.
isPtr bool | ||
} | ||
|
||
func (encoder *secretEncoder) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream) { |
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.
Looked at the examples here https://github.com/json-iterator/go/blob/master/extra/time_as_int64_codec.go
1d3b5d5
to
daca488
Compare
daca488
to
e5b8476
Compare
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.
Sorry for the ultra nits, logic is sound though, lgtm
Co-authored-by: Fayzal Ghantiwala <[email protected]>
#### What this PR does Update grafana/alerting and grafana/prometheus-alertmanager modules. [grafana/alerting diff](grafana/alerting@3e20fda...863b097): - grafana/alerting#347 - grafana/alerting#348 - grafana/alerting#349 [grafana/prometheus-alertmanager diff](grafana/prometheus-alertmanager@92c8f63...be61a67): - grafana/prometheus-alertmanager#117 The main change is the change of `WebhookConfig.Timeout` type from `time.Duration` to `model.Duration` to make marshalling to JSON and YAML the same. It does not affect YAML marshalling, only JSON and is needed for Grafana so in the future it can start sending JSON encoded configurations with alertmanager receivers. More details are in grafana/prometheus-alertmanager#117 #### Checklist - [ ] Tests updated. - [ ] Documentation added. - [ ] `CHANGELOG.md` updated - the order of entries should be `[CHANGE]`, `[FEATURE]`, `[ENHANCEMENT]`, `[BUGFIX]`. If changelog entry is not needed, please add the `changelog-not-needed` label to the PR. - [ ] [`about-versioning.md`](https://github.com/grafana/mimir/blob/main/docs/sources/mimir/configure/about-versioning.md) updated with experimental features.
This PR adds a custom JSON marshaler (
MarshalJSONWithSecrets
) that can serialize Alertmanager configurations with secrets in plain text rather than masked values. It usesjsoniter
to create custom encoders for secret types from Prometheus and Alertmanager.It is not used yet.
Prometheus Alertmanager uses a few types of secret structs:
During marshaling, secrets in these structs are masked (this can be controlled only via a global variable), but sometimes we need to preserve them and this PR adds a custom marshaler for these situations.
Part of https://github.com/grafana/alerting-squad/issues/1152