feat: allow nested details fields in pagerduty#3944
Conversation
e838ea9 to
47a3b07
Compare
4398f8e to
4200259
Compare
|
I don't think it is intentional that the default template is valid YAML, it's just meant to be plain text. I'd even argue it's meant to be Markdown. If I understand the use case, you would like to be able to add structured objects (with nesting) to the |
Correct, our teams prefer that so they can add logic on PagerDuty side depending on the field values. |
|
Have you considered changing // PagerdutyConfig configures notifications via PagerDuty.
type PagerdutyConfig struct {
...
Details map[string]interface{} `yaml:"details,omitempty" json:"details,omitempty"`
}Would this avoid having to embed YAML inside existing YAML? I haven't checked if this will affect existing configurations, but it would be good to understand if this is a better option. |
That was the initial approach I though about. It will create a free style format and would require checking the interfaces one by one as they can be either maps or templated strings. I'm open to experiment with it. |
|
Curious to know... Is this going forward ? |
|
I'll update this PR with the suggested |
4200259 to
20fa318
Compare
20fa318 to
6fc0d06
Compare
|
Thinking about this more, using a template like Parsing template results into maps or slices is possible but could be error-prone and we'd need a format for it. details: ...
details_include:
alerts: true
... |
e6def12 to
356e142
Compare
This change allows nested key/value pair in pageduty configuration. Events API V1 supports an object in `details` field: https://developer.pagerduty.com/docs/send-v1-event#parameters Events API V2 supports an object in `payload.custom_details` field: https://developer.pagerduty.com/docs/send-alert-event#parameters The configuration and message/payload types where changed from `map[string]string` to `map[string]any`. The default template is updated to use the new `toJson` function. Fixes prometheus#2477 Fixes prometheus#3218 Signed-off-by: Siavash Safi <siavash@cloudflare.com>
356e142 to
bb15bcc
Compare
|
@siavashs you are a true hero |
|
@siavashs For v1 integration, this seems to have changed the urls in label/annotations to not render as links in PD. PD used to make them clickable hyperlinks when |
|
@abhijith-db this sounds like a UI issue on PD side. |
|
@siavashs Yeah that's a workaround. Only problem is there's no global PD default template to configure. Each receiver has to use the non-json template to linkify urls in annotations |
|
I see, we'll add a global config for PagerDuty. |
|
@siavashs Also the deep copy with template was affecting this too. Had to fork and fix on our end to exclude string type. As: Failing testcase that would have passed before this change: It's a regression only because PD would render addresses in annotations etc as links which broke after this. |
|
This PR should be marked as potentially breaking changes in the changelog 😞. So, we were heavily reliant on the legacy non-JSON format, and we found that the hard way, unfortunately 😢. |

This change allows nested key/value pair in pageduty configuration.
Events API V1 supports an object in
detailsfield:https://developer.pagerduty.com/docs/send-v1-event#parameters
Events API V2 supports an object in
payload.custom_detailsfield:https://developer.pagerduty.com/docs/send-alert-event#parameters
The configuration and message/payload types where changed from
map[string]stringtomap[string]any.The default template is updated to use the new
toJsonfunction.Fixes #2477
Fixes #3218
Signed-off-by: Siavash Safi siavash@cloudflare.com