chore: upgrade gopkg.in/yaml to v3#3322
Closed
chengjoey wants to merge 1 commit intoprometheus:mainfrom
Closed
Conversation
use `decoder.KnownFields` instead of `UnmarshalStrict` Signed-off-by: joey <zchengjoey@gmail.com>
3b49c62 to
f197517
Compare
Member
|
We have good reasons not to upgrade to v3, as common and prometheus are stuck with v2. |
Contributor
Author
never mind, there is really no problem if don't upgrade to the v3 |
siavashs
added a commit
to siavashs/alertmanager
that referenced
this pull request
Aug 5, 2024
This change fixes the `custom_details` value in PagerDuty V2 API payloads. Fixes prometheus#2477 Fixes prometheus#3218 Alertmanager PagerDuty configuration allows users to define `details` under `pagerduty_configs`: ```yaml [ details: { <string>: <tmpl_string>, ... } | default = { firing: '{{ template "pagerduty.default.instances" .Alerts.Firing }}' resolved: '{{ template "pagerduty.default.instances" .Alerts.Resolved }}' num_firing: '{{ .Alerts.Firing | len }}' num_resolved: '{{ .Alerts.Resolved | len }}' } ] ``` The internal Alertmanager configuration structure is defined as: ```go // PagerdutyConfig configures notifications via PagerDuty. type PagerdutyConfig struct { ... Details map[string]string `yaml:"details,omitempty" json:"details,omitempty"` } ``` And the PagerDuty payload is defined as: ```go type pagerDutyPayload struct { ... CustomDetails map[string]string `json:"custom_details,omitempty"` ``` The current flow of configuration parsing and encoding is: 1. `pagerduty_configs[].details` are read from configuration as `map[string]string` 2. The `details` map values are parsed as text templates 3. `details` is encoded `custom_details` as part of the JSON payload sent to PagerDuty API V2 In the above example `.Alerts.Firing` returns a list of currently firing alert objects in this group. Documented here: https://prometheus.io/docs/alerting/latest/notifications/#data This results in a payload like below: ```json { "client": "Alertmanager", ... "firing": "Labels: - alertname = Server_Down ... Annotations: - summary = Server is down ... ", ... } ``` Using `map[string]string` in payloads cause the rendered YAML templates to be encoded as JSON strings. This is undesirable in most cases as the end-user might expect a nested JSON object. This change: - adds logic to unmarshall `details` values as YAML with fallback to string - uses `map[string]interface{}` to encode `custom_details` to JSON - requires gopkg.in/yaml.v3, see go-yaml/yaml#591 - does not change existing yaml.v2 dependency, see prometheus#3322 Signed-off-by: Siavash Safi <siavash@cloudflare.com>
siavashs
added a commit
to siavashs/alertmanager
that referenced
this pull request
Aug 5, 2024
This change fixes the `custom_details` value in PagerDuty V2 API payloads. Fixes prometheus#2477 Fixes prometheus#3218 Alertmanager PagerDuty configuration allows users to define `details` under `pagerduty_configs`: ```yaml [ details: { <string>: <tmpl_string>, ... } | default = { firing: '{{ template "pagerduty.default.instances" .Alerts.Firing }}' resolved: '{{ template "pagerduty.default.instances" .Alerts.Resolved }}' num_firing: '{{ .Alerts.Firing | len }}' num_resolved: '{{ .Alerts.Resolved | len }}' } ] ``` The internal Alertmanager configuration structure is defined as: ```go // PagerdutyConfig configures notifications via PagerDuty. type PagerdutyConfig struct { ... Details map[string]string `yaml:"details,omitempty" json:"details,omitempty"` } ``` And the PagerDuty payload is defined as: ```go type pagerDutyPayload struct { ... CustomDetails map[string]string `json:"custom_details,omitempty"` ``` The current flow of configuration parsing and encoding is: 1. `pagerduty_configs[].details` are read from configuration as `map[string]string` 2. The `details` map values are parsed as text templates 3. `details` is encoded `custom_details` as part of the JSON payload sent to PagerDuty API V2 In the above example `.Alerts.Firing` returns a list of currently firing alert objects in this group. Documented here: https://prometheus.io/docs/alerting/latest/notifications/#data This results in a payload like below: ```json { "client": "Alertmanager", ... "custom_details": { "firing": "Labels: - alertname = Server_Down ... Annotations: - summary = Server is down ... " } } ``` Using `map[string]string` in payloads cause the rendered YAML templates to be encoded as JSON strings. This is undesirable in most cases as the end-user might expect a nested JSON object. This change: - adds logic to unmarshall `details` values as YAML with fallback to string - uses `map[string]interface{}` to encode `custom_details` to JSON - requires gopkg.in/yaml.v3, see go-yaml/yaml#591 - does not change existing yaml.v2 dependency, see prometheus#3322 Signed-off-by: Siavash Safi <siavash@cloudflare.com>
siavashs
added a commit
to siavashs/alertmanager
that referenced
this pull request
Aug 5, 2024
This change fixes the `custom_details` value in PagerDuty V2 API payloads. Fixes prometheus#2477 Fixes prometheus#3218 Alertmanager PagerDuty configuration allows users to define `details` under `pagerduty_configs`: ```yaml [ details: { <string>: <tmpl_string>, ... } | default = { firing: '{{ template "pagerduty.default.instances" .Alerts.Firing }}' resolved: '{{ template "pagerduty.default.instances" .Alerts.Resolved }}' num_firing: '{{ .Alerts.Firing | len }}' num_resolved: '{{ .Alerts.Resolved | len }}' } ] ``` The internal Alertmanager configuration structure is defined as: ```go // PagerdutyConfig configures notifications via PagerDuty. type PagerdutyConfig struct { ... Details map[string]string `yaml:"details,omitempty" json:"details,omitempty"` } ``` And the PagerDuty payload is defined as: ```go type pagerDutyPayload struct { ... CustomDetails map[string]string `json:"custom_details,omitempty"` ``` The current flow of configuration parsing and encoding is: 1. `pagerduty_configs[].details` are read from configuration as `map[string]string` 2. The `details` map values are parsed as text templates 3. The result is passed as `custom_details`, part of the JSON payload sent to PagerDuty API V2 Here is an example payload using `.Alerts.Firing`, which returns a list of currently firing alert objects in this group. Documented here: https://prometheus.io/docs/alerting/latest/notifications/#data This results in a payload like below: ```json { "client": "Alertmanager", ... "custom_details": { "firing": "Labels: - alertname = Server_Down ... Annotations: - summary = Server is down ... " } } ``` Using `map[string]string` in payloads cause the rendered YAML templates to be encoded as JSON strings. This is undesirable in most cases as the end-user might expect a nested JSON object which is machine readable/parsable by it's fields. This change: - adds logic to unmarshall `details` values as YAML with fallback to string - uses `map[string]interface{}` to encode `custom_details` to JSON - requires gopkg.in/yaml.v3, see go-yaml/yaml#591 - does not change existing yaml.v2 dependency, see prometheus#3322 Signed-off-by: Siavash Safi <siavash@cloudflare.com>
siavashs
added a commit
to siavashs/alertmanager
that referenced
this pull request
Aug 5, 2024
This change fixes the `custom_details` value in PagerDuty V2 API payloads. Fixes prometheus#2477 Fixes prometheus#3218 Alertmanager PagerDuty configuration allows users to define `details` under `pagerduty_configs`: ```yaml [ details: { <string>: <tmpl_string>, ... } | default = { firing: '{{ template "pagerduty.default.instances" .Alerts.Firing }}' resolved: '{{ template "pagerduty.default.instances" .Alerts.Resolved }}' num_firing: '{{ .Alerts.Firing | len }}' num_resolved: '{{ .Alerts.Resolved | len }}' } ] ``` The internal Alertmanager configuration structure is defined as: ```go // PagerdutyConfig configures notifications via PagerDuty. type PagerdutyConfig struct { ... Details map[string]string `yaml:"details,omitempty" json:"details,omitempty"` } ``` And the PagerDuty payload is defined as: ```go type pagerDutyPayload struct { ... CustomDetails map[string]string `json:"custom_details,omitempty"` } ``` The current flow of configuration parsing and encoding is: 1. `pagerduty_configs[].details` are read from configuration as `map[string]string` 2. The `details` map values are parsed as text templates 3. The result is passed as `custom_details`, part of the JSON payload sent to PagerDuty API V2 Here is an example payload using `.Alerts.Firing`, which returns a list of currently firing alert objects in this group. Documented here: https://prometheus.io/docs/alerting/latest/notifications/#data This results in a payload like below: ```json { "client": "Alertmanager", ... "custom_details": { "firing": "Labels: - alertname = Server_Down ... Annotations: - summary = Server is down ... " } } ``` Using `map[string]string` in payloads cause the rendered YAML templates to be encoded as JSON strings. This is undesirable in most cases as the end-user might expect a nested JSON object which is machine readable/parsable by it's fields. This change: - adds logic to unmarshall `details` values as YAML with fallback to string - uses `map[string]interface{}` to encode `custom_details` to JSON - requires gopkg.in/yaml.v3, see go-yaml/yaml#591 - does not change existing yaml.v2 dependency, see prometheus#3322 Signed-off-by: Siavash Safi <siavash@cloudflare.com>
siavashs
added a commit
to siavashs/alertmanager
that referenced
this pull request
Aug 5, 2024
This change fixes the `custom_details` value in PagerDuty V2 API payloads. Fixes prometheus#2477 Fixes prometheus#3218 Alertmanager PagerDuty configuration allows users to define `details` under `pagerduty_configs`: ```yaml [ details: { <string>: <tmpl_string>, ... } | default = { firing: '{{ template "pagerduty.default.instances" .Alerts.Firing }}' resolved: '{{ template "pagerduty.default.instances" .Alerts.Resolved }}' num_firing: '{{ .Alerts.Firing | len }}' num_resolved: '{{ .Alerts.Resolved | len }}' } ] ``` The internal Alertmanager configuration structure is defined as: ```go // PagerdutyConfig configures notifications via PagerDuty. type PagerdutyConfig struct { ... Details map[string]string `yaml:"details,omitempty" json:"details,omitempty"` } ``` And the PagerDuty payload is defined as: ```go type pagerDutyPayload struct { ... CustomDetails map[string]string `json:"custom_details,omitempty"` } ``` The current flow of configuration parsing and encoding is: 1. `pagerduty_configs[].details` are read from configuration as `map[string]string` 2. The `details` map values are parsed as text templates 3. The result is passed as `custom_details`, part of the JSON payload sent to PagerDuty API V2 Here is an example payload using `.Alerts.Firing`, which returns a list of currently firing alert objects in this group. Documented here: https://prometheus.io/docs/alerting/latest/notifications/#data This results in a payload like below: ```json { "client": "Alertmanager", ... "custom_details": { "firing": "Labels: - alertname = Server_Down ... Annotations: - summary = Server is down ... " } } ``` Using `map[string]string` in payloads cause the rendered YAML templates to be encoded as JSON strings. This is undesirable in most cases as the end-user might expect a nested JSON object which is machine readable/parsable by it's fields. This change: - adds logic to unmarshall `details` values as YAML with fallback to string - uses `map[string]interface{}` to encode `custom_details` to JSON - requires gopkg.in/yaml.v3, see go-yaml/yaml#591 - does not change existing yaml.v2 dependency, see prometheus#3322 Signed-off-by: Siavash Safi <siavash@cloudflare.com>
siavashs
added a commit
to siavashs/alertmanager
that referenced
this pull request
Aug 5, 2024
This change fixes the `custom_details` value in PagerDuty V2 API payloads. Fixes prometheus#2477 Fixes prometheus#3218 Alertmanager PagerDuty configuration allows users to define `details` under `pagerduty_configs`: ```yaml [ details: { <string>: <tmpl_string>, ... } | default = { firing: '{{ template "pagerduty.default.instances" .Alerts.Firing }}' resolved: '{{ template "pagerduty.default.instances" .Alerts.Resolved }}' num_firing: '{{ .Alerts.Firing | len }}' num_resolved: '{{ .Alerts.Resolved | len }}' } ] ``` The internal Alertmanager configuration structure is defined as: ```go // PagerdutyConfig configures notifications via PagerDuty. type PagerdutyConfig struct { ... Details map[string]string `yaml:"details,omitempty" json:"details,omitempty"` } ``` And the PagerDuty payload is defined as: ```go type pagerDutyPayload struct { ... CustomDetails map[string]string `json:"custom_details,omitempty"` } ``` The current flow of configuration parsing and encoding is: 1. `pagerduty_configs[].details` are read from configuration as `map[string]string` 2. The `details` map values are parsed as text templates 3. The result is passed as `custom_details`, part of the JSON payload sent to PagerDuty API V2 Here is an example payload using `.Alerts.Firing`, which returns a list of currently firing alert objects in this group. Documented here: https://prometheus.io/docs/alerting/latest/notifications/#data This results in a payload like below: ```json { "client": "Alertmanager", ... "custom_details": { "firing": "Labels: - alertname = Server_Down ... Annotations: - summary = Server is down ... " } } ``` Using `map[string]string` in payloads cause the rendered YAML templates to be encoded as JSON strings. This is undesirable in most cases as the end-user might expect a nested JSON object which is machine readable/parsable by it's fields. This change: - adds logic to unmarshall `details` values as YAML with fallback to string - uses `map[string]interface{}` to encode `custom_details` to JSON - requires gopkg.in/yaml.v3, see go-yaml/yaml#591 - does not change existing yaml.v2 dependency, see prometheus#3322 Signed-off-by: Siavash Safi <siavash@cloudflare.com>
siavashs
added a commit
to siavashs/alertmanager
that referenced
this pull request
Aug 5, 2024
This change fixes the `custom_details` value in PagerDuty V2 API payloads. Fixes prometheus#2477 Fixes prometheus#3218 Alertmanager PagerDuty configuration allows users to define `details` under `pagerduty_configs`: ```yaml [ details: { <string>: <tmpl_string>, ... } | default = { firing: '{{ template "pagerduty.default.instances" .Alerts.Firing }}' resolved: '{{ template "pagerduty.default.instances" .Alerts.Resolved }}' num_firing: '{{ .Alerts.Firing | len }}' num_resolved: '{{ .Alerts.Resolved | len }}' } ] ``` The internal Alertmanager configuration structure is defined as: ```go // PagerdutyConfig configures notifications via PagerDuty. type PagerdutyConfig struct { ... Details map[string]string `yaml:"details,omitempty" json:"details,omitempty"` } ``` And the PagerDuty payload is defined as: ```go type pagerDutyPayload struct { ... CustomDetails map[string]string `json:"custom_details,omitempty"` } ``` The current flow of configuration parsing and encoding is: 1. `pagerduty_configs[].details` are read from configuration as `map[string]string` 2. The `details` map values are parsed as text templates 3. The result is passed as `custom_details`, part of the JSON payload sent to PagerDuty API V2 Here is an example payload using `.Alerts.Firing`, which returns a list of currently firing alert objects in this group. Documented here: https://prometheus.io/docs/alerting/latest/notifications/#data This results in a payload like below: ```json { "client": "Alertmanager", ... "custom_details": { "firing": "Labels: - alertname = Server_Down ... Annotations: - summary = Server is down ... " } } ``` Using `map[string]string` in payloads cause the rendered YAML templates to be encoded as JSON strings. This is undesirable in most cases as the end-user might expect a nested JSON object which is machine readable/parsable by it's fields. This change: - adds logic to unmarshall `details` values as YAML with fallback to string - uses `map[string]interface{}` to encode `custom_details` to JSON - requires gopkg.in/yaml.v3, see go-yaml/yaml#591 - does not change existing yaml.v2 dependency, see prometheus#3322 Signed-off-by: Siavash Safi <siavash@cloudflare.com>
siavashs
added a commit
to siavashs/alertmanager
that referenced
this pull request
Oct 13, 2025
This change fixes the `custom_details` value in PagerDuty V2 API payloads. Fixes prometheus#2477 Fixes prometheus#3218 Alertmanager PagerDuty configuration allows users to define `details` under `pagerduty_configs`: ```yaml [ details: { <string>: <tmpl_string>, ... } | default = { firing: '{{ template "pagerduty.default.instances" .Alerts.Firing }}' resolved: '{{ template "pagerduty.default.instances" .Alerts.Resolved }}' num_firing: '{{ .Alerts.Firing | len }}' num_resolved: '{{ .Alerts.Resolved | len }}' } ] ``` The internal Alertmanager configuration structure is defined as: ```go // PagerdutyConfig configures notifications via PagerDuty. type PagerdutyConfig struct { ... Details map[string]string `yaml:"details,omitempty" json:"details,omitempty"` } ``` And the PagerDuty payload is defined as: ```go type pagerDutyPayload struct { ... CustomDetails map[string]string `json:"custom_details,omitempty"` } ``` The current flow of configuration parsing and encoding is: 1. `pagerduty_configs[].details` are read from configuration as `map[string]string` 2. The `details` map values are parsed as text templates 3. The result is passed as `custom_details`, part of the JSON payload sent to PagerDuty API V2 Here is an example payload using `.Alerts.Firing`, which returns a list of currently firing alert objects in this group. Documented here: https://prometheus.io/docs/alerting/latest/notifications/#data This results in a payload like below: ```json { "client": "Alertmanager", ... "custom_details": { "firing": "Labels: - alertname = Server_Down ... Annotations: - summary = Server is down ... " } } ``` Using `map[string]string` in payloads cause the rendered YAML templates to be encoded as JSON strings. This is undesirable in most cases as the end-user might expect a nested JSON object which is machine readable/parsable by it's fields. This change: - adds logic to unmarshall `details` values as YAML with fallback to string - uses `map[string]interface{}` to encode `custom_details` to JSON - requires gopkg.in/yaml.v3, see go-yaml/yaml#591 - does not change existing yaml.v2 dependency, see prometheus#3322 Signed-off-by: Siavash Safi <siavash@cloudflare.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
use
decoder.KnownFieldsinstead ofUnmarshalStrictadd
MarshalYamlfunc forTimeInterval#3267