The previous implementation used strings.Replace to change '/2' to '/3'
in the API URL path, but this incorrectly matched and replaced the '2'
in hostnames containing that character (e.g., 'example2.atlassian.net'),
resulting in malformed URLs like 'https://example3.atlassian.net/...'.
This fix makes the replacement more specific by targeting the full
'/rest/api/2/' path instead of just '/2', ensuring only the API version
in the path is modified, not characters in the hostname.
Signed-off-by: alex-deploys <alex-deploys@users.noreply.github.com>
Co-authored-by: alex-deploys <alex-deploys@users.noreply.github.com>
The code in the two selects in case ctx is done is exactly the same.
Remove the second copy, the first one will be reached via the for loop.
Signed-off-by: Rudolf Thomas <rudolf.thomas@firma.seznam.cz>
Add tracing support using otel to the the following components:
- api: extract trace and span IDs from request context
- provider: mem put
- dispatch: split logic and use better naming
- inhibit: source and target traces, mutes, etc. drop metrics
- silence: query, expire, mutes
- notify: add distributed tracing support to stages and all http requests
Note: inhibitor metrics are dropped since we have tracing now and they
are not needed. We have not released any version with these metrics so
we can drop them safely, this is not a breaking change.
This change borrows part of the implementation from #3673
Fixes #3670
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Signed-off-by: Siavash Safi <siavash@cloudflare.com>
Co-authored-by: Dave Henderson <dhenderson@gmail.com>
* jira: add additional test case for Fields
This ensures we don't have a regression in this area.
Signed-off-by: Solomon Jacobs <solomonjacobs@protonmail.com>
* chore: remove trivago
This dependency is unmaintained and has recently been archived. The
function we used is equivalent to:
```go
import "reflect"
func TryConvertToMarshalMap(value any) any {
valueMeta := reflect.ValueOf(value)
switch valueMeta.Kind() {
case reflect.Array, reflect.Slice:
arrayLen := valueMeta.Len()
converted := make([]any, arrayLen)
for i := range arrayLen {
converted[i] = TryConvertToMarshalMap(valueMeta.Index(i).Interface())
}
return converted
case reflect.Map:
converted := make(map[string]any)
keys := valueMeta.MapKeys()
for _, keyMeta := range keys {
strKey, isString := keyMeta.Interface().(string)
if !isString {
continue
}
val := valueMeta.MapIndex(keyMeta).Interface()
converted[strKey] = TryConvertToMarshalMap(val)
}
return converted
default:
return value
}
}
```
So, all it does is replace `map` types with `map[string]any` and skip
keys, which are not of type string. However, `DeepCopyWithTemplate`
already does this with the only difference being that it passes
`len(keys)` as a capacity.
Moreover, `ConvertToMarshalMap` does not return an error, if one passes
an object of type `map`. So, the extra error check was redundant as
well.
In other words, omitting this function call does not affect behaviour.
Signed-off-by: Solomon Jacobs <solomonjacobs@protonmail.com>
---------
Signed-off-by: Solomon Jacobs <solomonjacobs@protonmail.com>
Some email clients such as Gmail apparently use their own heuristics
for threading and already implement this behavior based on the subject.
But for users of other email clients that only implement threading
based on the relevant headers (e.g. notmuch), those users currently
get one email thread for each newly firing alert.
With threading enabled, all alert emails (of the same alert)
on the same day are grouped into the same thread. Much nicer :)
Signed-off-by: Michael Stapelberg <stapelberg@google.com>
* ref(webhook): return error if unable to parse group key
Addresses feedback from another PR
https://github.com/prometheus/alertmanager/pull/4089#discussion_r1824480384
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
* fix(silence): log errors at ERROR level instead of INFO
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
* chore(notify): make logging more consistent, converge on `group_key`
This changes the majority of our `Notify()` implementations to set up a
new logger with the group key attached under the key name `group_key`,
and then to use that logger in all subsequent calls to the logger,
including passing it through to further functions that accept loggers
via params.
A few of the notify implementations are more complicated; they either
extract the key later in their `Notify()` implementation or within sub
methods, or even conditionally like with sns. I left those mostly as is
for now, as they seem to be more snow-flake-y.
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
---------
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
A lot of tests create temporary files. Only one cleans up.
Use t.TempDir() in the CreateTemp calls, to get automatic cleanup.
Signed-off-by: Guido Trotter <guido@hudson-trading.com>
Co-authored-by: Guido Trotter <guido@hudson-trading.com>
* Update CI test to include maildev tests
Signed-off-by: Joe Adams <github@joeadams.io>
* Update test comments about maildev
Signed-off-by: Joe Adams <github@joeadams.io>
* Disable CircleCI workflows
Signed-off-by: Joe Adams <github@joeadams.io>
* Fix Circle config
Signed-off-by: Joe Adams <github@joeadams.io>
---------
Signed-off-by: Joe Adams <github@joeadams.io>
* Update Go to 1.25.
* Update minimum Go version to 1.24.0.
* Group github.com/go-openapi dependencies.
* Enable dependabot for github actions.
Signed-off-by: SuperQ <superq@gmail.com>
* Add new Jira search endpoint with new api_type option and auto detect
Signed-off-by: christianjedro <cj@cloudeteer.de>
* adding recommendations, update doku, add comments
Signed-off-by: christianjedro <cj@cloudeteer.de>
* remove global api type (recommended by @jkroepke), add default value and remove test + implementation for empty string
Signed-off-by: christianjedro <cj@cloudeteer.de>
* dco
Signed-off-by: christianjedro <cj@cloudeteer.de>
* add better explanation
Signed-off-by: christianjedro <cj@cloudeteer.de>
---------
Signed-off-by: christianjedro <cj@cloudeteer.de>
Rather than carefully trying to shrink the size of the payload to fit
the 512kB limit, just try two encodings:
1. The full original message; and
2. Remove all but the first alert in the group and send that
For most configurations, each message creates a single alert in
incident.io, with the details of the alerts which made up that group
contained within being useful but not essential.
This means the code is a lot simpler, and does at-most 2 JSON encodings
for each message (although in general it should be pretty rare to need
to do more than 1!)
Signed-off-by: Isaac Seymour <i.seymour@oxon.org>
- Adds the technical implementation, and tests, for the incident.io notifier
- Configured through the following config:
```yaml
receivers:
- name: 'incidentio-notifications'
incidentio_configs:
- url: '$alert_source_url'
alert_source_token: '$alert_source_token'
```
- Add documentation for the incidentio_config
Signed-off-by: Isaac Seymour <i.seymour@oxon.org>