prometheus-community / jiralert

JIRA integration for Prometheus Alertmanager
Apache License 2.0
335 stars 130 forks source link

issues="unsupported value type" picked="unsupported value type" #185

Open VaaFull opened 7 months ago

VaaFull commented 7 months ago

Hello team I've got an issue with https://github.com/prometheus-community/jiralert/blob/master/pkg/notify/notify.go#L337 It seems like variables issuesand issuereturned some wrong data. If we check logs, queryshows with no error, but for the last 2 variables I've got the issue - unsupported value type "query", query, "issues", issues, "picked", issue

I took some logs to get better understanding. It is the same logs, but in different output

So the first one is default logs format tell us:

level=warn ts=2024-03-13T14:38:23.351923702Z caller=notify.go:337 msg="more than one issue matched, picking most recently resolved" query="project in('ITDPL') and labels=\"JIRALERT{153c989daecc938ce2e36d47......1cae62a0475ca415c238b824556e2192e1148}\" order by resolutiondate desc" issues="unsupported value type" picked="unsupported value type"

Next is DEBUG level

level=debug ts=2024-03-13T14:26:23.121607584Z caller=notify.go:323 msg=search query="project in('ITDPL') and labels=\"JIRALERT{153c989daecc938ce98fc1025b.......16c1cae62a0475ca415c238b824556e2192e1148}\" order by resolutiondate desc" options="&{StartAt:0 MaxResults:2 Expand: Fields:[summary status resolution resolutiondate description comment] ValidateQuery:}"
level=warn ts=2024-03-13T14:26:23.386894917Z caller=notify.go:337 msg="more than one issue matched, picking most recently resolved" query="project in('ITDPL') and labels=\"JIRALERT{153c989daecc938.........6c1cae62a0475ca415c238b824556e2192e1148}\" order by resolutiondate desc" issues="unsupported value type" picked="unsupported value type"

Next DEBUG JSON


{"caller":"notify.go:337","issues":[{"expand":"operations,versionedRepresentations,editmeta,changelog,renderedFields","id":"3741735","self":"https://gtsaaa.aaa.com/rest/api/2/issue/3741735","key":"ITDPL-54439","fields":{"status":{"description":"The issue is open and ready for the assignee to start work on it.","iconUrl":"https://gtsaaa.aaa.com/images/icons/statuses/open.png","id":"1","name":"Open","self":"https://gtsaaa.aaa.com/rest/api/2/status/1","statusCategory":{"colorName":"default","id":2,"key":"new","name":"To Do","self":"https://gtsaaa.aaa.com/rest/api/2/statuscategory/2"}},"summary":"[FIRING:1] TEST-PVC,aaa,postgres-main"}},{"expand":"operations,versionedRepresentations,editmeta,changelog,renderedFields","id":"3741684","self":"https://gtsaaa.aaa.com/rest/api/2/issue/3741684","key":"ITDPL-54436","fields":{"resolutiondate":"2024-03-11T10:17:08.000-0400","status":{"description":"A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.","iconUrl":"https://gtsaaa.aaa.com/images/icons/statuses/resolved.png","id":"5","name":"Resolved","self":"https://gtsaaa.aaa.com/rest/api/2/status/5","statusCategory":{"colorName":"success","id":3,"key":"done","name":"Done","self":"https://gtsaaa.aaa.com/rest/api/2/statuscategory/3"}},"summary":"[FIRING:1] TEST-PVC,aaa,postgres-main"}}],"level":"warn","msg":"more than one issue matched, picking most recently resolved","picked":{"expand":"operations,versionedRepresentations,editmeta,changelog,renderedFields","id":"3741735","self":"https://gtsaaa.aaa.com/rest/api/2/issue/3741735","key":"ITDPL-54439","fields":{"status":{"description":"The issue is open and ready for the assignee to start work on it.","iconUrl":"https://gtsaaa.aaa.com/images/icons/statuses/open.png","id":"1","name":"Open","self":"https://gtsaaa.aaa.com/rest/api/2/status/1","statusCategory":{"colorName":"default","id":2,"key":"new","name":"To Do","self":"https://gtsaaa.aaa.com/rest/api/2/statuscategory/2"}},"summary":"[FIRING:1] TEST-PVC,aaa,postgres-main"}},"query":"project in('ITDPL') and labels=\"JIRALERT{153c989daecc938ce98.........ca415c238b824556e2192e1148}\" order by resolutiondate desc","ts":"2024-03-13T13:26:23.214364566Z"}
{"caller":"notify.go:340","issue":{"expand":"operations,versionedRepresentations,editmeta,changelog,renderedFields","id":"3741735","self":"https://gtsaaa.aaa.com/rest/api/2/issue/3741735","key":"ITDPL-54439","fields":{"status":{"description":"The issue is open and ready for the assignee to start work on it.","iconUrl":"https://gtsaaa.aaa.com/images/icons/statuses/open.png","id":"1","name":"Open","self":"https://gtsaaa.aaa.com/rest/api/2/status/1","statusCategory":{"colorName":"default","id":2,"key":"new","name":"To Do","self":"https://gtsaaa.aaa.com/rest/api/2/statuscategory/2"}},"summary":"[FIRING:1] TEST-PVC,aaa,postgres-main"}},"level":"debug","msg":"found","query":"project in('ITDPL') and labels=\"JIRALERT{153c989daecc938ce98........38b824556e2192e1148}\" order by resolutiondate desc","ts":"2024-03-13T13:26:23.214785765Z"}```
madddi commented 1 month ago

Hi @VaaFull, I'm running into the same issue. Did you find out what the problem was?

banuchka commented 2 weeks ago

The issue is only about the log message. I put a small fix to get the correct output:

diff --git a/pkg/notify/notify.go b/pkg/notify/notify.go
index e4b96a2..9b5c25f 100644
--- a/pkg/notify/notify.go
+++ b/pkg/notify/notify.go
@@ -334,7 +334,13 @@ func (r *Receiver) search(projects []string, issueLabel string) (*jira.Issue, bo

        issue := issues[0]
        if len(issues) > 1 {
-               level.Warn(r.logger).Log("msg", "more than one issue matched, picking most recently resolved", "query", query, "issues", issues, "picked", issue)
+               // level.Warn(r.logger).Log("msg", "more than one issue matched, picking most recently resolved", "query", query, "issues", issues, "picked", issue)
+               keys := make([]string, len(issues))
+               for i, iss := range issues {
+                       keys[i] = iss.Key
+               }
+               issuesKeys := strings.Join(keys, ", ")
+               level.Warn(r.logger).Log("msg", "more than one issue matched, picking most recently resolved", "query", query, "issues", issuesKeys, "picked", issue.Key)
        }

        level.Debug(r.logger).Log("msg", "found", "issue", issue, "query", query)
VaaFull commented 1 week ago

@banuchka fast test shows - it works, thank you!

VaaFull commented 4 days ago

@banuchka one more place to change variable level=debug ts=2024-10-18T04:01:53.473381514Z caller=notify.go:345 msg=found issue="unsupported value type" query=

The issue is only about the log message. I put a small fix to get the correct output:

diff --git a/pkg/notify/notify.go b/pkg/notify/notify.go
index e4b96a2..9b5c25f 100644
--- a/pkg/notify/notify.go
+++ b/pkg/notify/notify.go
@@ -334,7 +334,13 @@ func (r *Receiver) search(projects []string, issueLabel string) (*jira.Issue, bo

        issue := issues[0]
        if len(issues) > 1 {
-               level.Warn(r.logger).Log("msg", "more than one issue matched, picking most recently resolved", "query", query, "issues", issues, "picked", issue)
+               // level.Warn(r.logger).Log("msg", "more than one issue matched, picking most recently resolved", "query", query, "issues", issues, "picked", issue)
+               keys := make([]string, len(issues))
+               for i, iss := range issues {
+                       keys[i] = iss.Key
+               }
+               issuesKeys := strings.Join(keys, ", ")
+               level.Warn(r.logger).Log("msg", "more than one issue matched, picking most recently resolved", "query", query, "issues", issuesKeys, "picked", issue.Key)
        }

        level.Debug(r.logger).Log("msg", "found", "issue", issue, "query", query)

level.Debug(r.logger).Log("msg", "found", "issue", issue.Key, "query", query)