Support adding custom fields to VictorOps notifications#1420
Support adding custom fields to VictorOps notifications#1420stuartnelson3 merged 6 commits intoprometheus:masterfrom
Conversation
48efbb4 to
5a9deb0
Compare
simonpasquier
left a comment
There was a problem hiding this comment.
A few comments but looks good overall.
notify/impl.go
Outdated
| return n.retry(resp.StatusCode) | ||
| } | ||
|
|
||
| //Create the json payload to be sent to victorops api |
There was a problem hiding this comment.
(nit) add a space before Create + missing dot + s/json/JSON/
There was a problem hiding this comment.
fixed the space. whats the second part about the DOT?
notify/impl.go
Outdated
| return nil, fmt.Errorf("templating error: %s", err) | ||
| } | ||
| } else { | ||
| level.Debug(n.logger).Log("msg", "Ignoring custom field %q as it is already defined as a fixed field", "omitted_field", k, "incident", key) |
There was a problem hiding this comment.
You need to remove the %q formatter in the message.
level.Debug(n.logger).Log("msg", "Ignoring custom field as it is already defined as a fixed field", "field", k, "incident", key)|
Thank you for the feedback @simonpasquier . I have incorporated the changes |
simonpasquier
left a comment
There was a problem hiding this comment.
Still a few minor nits. I guess you have the opportunity to test the change against the VictorOps API?
notify/impl.go
Outdated
| return n.retry(resp.StatusCode) | ||
| } | ||
|
|
||
| // Create the json payload to be sent to victorops api |
There was a problem hiding this comment.
Either add a dot at the end or simply remove the comment since it is pretty clear from the function name what it is doing.
notify/impl_test.go
Outdated
| //Verify the invalid custom field didn't override the static field | ||
| require.Equal(t, "message", m["state_message"]) | ||
|
|
||
| //Verify that a custom field was added to the payload and templatized |
93f5a70 to
31a0576
Compare
|
Sorry for the delay. I went ahead and added validation to the config load logic of Victorops. I left the notifier logic in place, it felt appropriate to keep it there as an extra safety net. Thanks for the feedback @brian-brazil |
notify/impl_test.go
Outdated
| MonitoringTool: `AM`, | ||
| CustomFields: map[string]string{ | ||
| "Field_A": "{{ .CommonLabels.Message }}", | ||
| //A field that should be ignored |
9561337 to
e32e5d0
Compare
simonpasquier
left a comment
There was a problem hiding this comment.
A few minor comments otherwise LGTM.
| * [CHANGE] Validate Slack field config and only allow the necessary input (#1334) | ||
| * [CHANGE] Remove legacy alert ingest endpoint (#1362) | ||
| * [CHANGE] Moved to memberlist as underlying gossip protocol | ||
| * [CHANGE] Move to memberlist as underlying gossip protocol including cluster flag changes from --mesh.xxx to --cluster.xxx (#1232) |
There was a problem hiding this comment.
Not sure why you got this change included.
notify/impl.go
Outdated
| return n.retry(resp.StatusCode) | ||
| } | ||
|
|
||
| // Create the json payload to be sent to victorops api |
There was a problem hiding this comment.
Either add a dot at the end or simply remove the comment since it is pretty clear from the function name what it is doing.
|
Hi, any progress here? I would like to use that feature. :) |
|
@jrthrawny can you resolve the conflicts and address the comments? |
|
Hi, |
|
Hello. I will rebase this PR and incorporate the changes suggested in feedback |
Signed-off-by: Jason Roberts <jroberts@drud.com>
Signed-off-by: Jason Roberts <jroberts@drud.com>
Signed-off-by: Jason Roberts <jroberts@drud.com>
Signed-off-by: Jason Roberts <jroberts@drud.com>
Signed-off-by: Jason Roberts <jroberts@drud.com>
e32e5d0 to
4952cc0
Compare
|
I've rebased this from master and cleaned up the comment grammar. Let me know if there is anything else I need to do. Sorry again for the delay |
simonpasquier
left a comment
There was a problem hiding this comment.
LGTM. Only one small remark on a comment.
notify/impl.go
Outdated
| return n.retry(resp.StatusCode) | ||
| } | ||
|
|
||
| // Create the json payload to be sent to victorops api. |
There was a problem hiding this comment.
s/json/JSON/
s/victorops api/the VictorOps API/
simonpasquier
left a comment
There was a problem hiding this comment.
You miss the DCO on the last commit otherwise 👍
Signed-off-by: Jason Roberts <jroberts@drud.com>
4d0a73f to
b23f2c6
Compare
|
signed :) |
|
Just saw this! Maybe @mxinden can add it to the 0.16.0 beta pr :) |
) * Support adding custom fields to VictorOps notifications * Response to feedback * Added logic to validate victorops custom fields to config load time * Cleanup victorops notifier of logic duplicated in config check * rebase and further cleanup from feedback * another grammer fix Signed-off-by: Jason Roberts <jroberts@drud.com>
|
Thanks for the pointer @stuartnelson3. Added to #1708. |
This PR is a followup to another PR that was opened #1315.
These changes allow users to define additional fields they would like to pass on to VictorOps and use templates to set the values of those fields.
Example:
Logic has been added to prevent a custom field colliding with/overriding a statically defined field. When this occurs, the field will simply be ignored and a debug level log message will notify of this.