fix(project): don't use status api

This commit is contained in:
Łukasz Mierzwa
2024-04-03 13:45:21 +01:00
committed by Łukasz Mierzwa
parent 19d8292a96
commit 1cd7856dc3
83 changed files with 121 additions and 1854 deletions

View File

@@ -1,5 +1,13 @@
# Changelog
## v0.120
### Changed
- Karma no longer uses alertmanager `api/v2/status` to discover cluster peers.
It will only rely on `cluster` field configuration options set in karma config
file.
## v0.119
### Fixed

View File

@@ -92,10 +92,9 @@ func getUpstreams() models.AlertmanagerAPISummary {
upstreams := alertmanager.GetAlertmanagers()
for _, upstream := range upstreams {
members := upstream.ClusterMemberNames()
clusterName := upstream.ClusterName()
if _, found := clusters[clusterName]; !found {
clusters[clusterName] = members
if _, found := clusters[upstream.Cluster]; !found {
clusters[upstream.Cluster] = members
}
u := models.AlertmanagerAPIStatus{
@@ -107,7 +106,7 @@ func getUpstreams() models.AlertmanagerAPISummary {
CORSCredentials: upstream.CORSCredentials,
Error: upstream.Error(),
Version: upstream.Version(),
Cluster: clusterName,
Cluster: upstream.Cluster,
ClusterMembers: members,
}
if !upstream.ProxyRequests {

View File

@@ -827,7 +827,10 @@ func TestVerifyAllGroups(t *testing.T) {
am, foundAM := ur.Silences["default"]
if !foundAM {
t.Errorf("[%s] Alertmanager cluster 'default' (default) missing from silences", version)
t.Errorf("[%s] Alertmanager cluster 'default' missing from silences", version)
for name := range ur.Silences {
t.Logf("Cluster: %s", name)
}
} else if len(am) == 0 {
t.Errorf("[%s] Silences mismatch, expected >0 but got %d", version, len(am))
}

View File

@@ -84,7 +84,6 @@ func TestAuthHeader(t *testing.T) {
for _, m := range []string{
"metrics",
"api/v2/status",
"api/v2/silences",
"api/v2/alerts/groups",
} {

View File

@@ -563,7 +563,6 @@ func TestProxyUserRewrite(t *testing.T) {
apiCache, _ = lru.New[string, []byte](100)
httpmock.Reset()
mock.RegisterURL("http://localhost/metrics", version, "metrics")
mock.RegisterURL("http://localhost/api/v2/status", version, "api/v2/status")
mock.RegisterURL("http://localhost/api/v2/silences", version, "api/v2/silences")
mock.RegisterURL("http://localhost/api/v2/alerts/groups", version, "api/v2/alerts/groups")
_ = am.Pull(intern.New())
@@ -1337,7 +1336,6 @@ func TestProxySilenceACL(t *testing.T) {
apiCache, _ = lru.New[string, []byte](100)
httpmock.Reset()
mock.RegisterURL("http://localhost/metrics", version, "metrics")
mock.RegisterURL("http://localhost/api/v2/status", version, "api/v2/status")
mock.RegisterURL("http://localhost/api/v2/silences", version, "api/v2/silences")
mock.RegisterURL("http://localhost/api/v2/alerts/groups", version, "api/v2/alerts/groups")
_ = am.Pull(intern.New())
@@ -1432,13 +1430,6 @@ func TestProxyRequestToUnsupportedAlertmanager(t *testing.T) {
httpmock.Reset()
httpmock.RegisterResponder("GET", "http://localhost/metrics", httpmock.NewStringResponder(200, `alertmanager_build_info{version="0.1.0"} 1
`))
httpmock.RegisterResponder("GET", "http://localhost/api/v2/status", httpmock.NewStringResponder(200, `{
"cluster": {
"name": "BBBBBBBBBBBBBBBBBBBBBBBBBB",
"peers": [],
"status": "ready"
}
}`))
httpmock.RegisterResponder("POST", "http://localhost/api/v2/silences", httpmock.NewStringResponder(200, "{}"))
httpmock.RegisterResponder("GET", "http://localhost/api/v2/silences", httpmock.NewStringResponder(200, "[]"))
httpmock.RegisterResponder("GET", "http://localhost/api/v2/alerts/groups", httpmock.NewStringResponder(200, "[]"))

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=info msg="Parsed ACL rules" rules=6
level=info msg="Configuration is valid"

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="failed to parse silence ACL configuration file \"acl.yaml\": yaml: unmarshal errors:\n line 1: cannot unmarshal !!str `This Is...` into config.SilencesACLSchema"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="failed to load silence ACL configuration file \"acl.yaml\": open acl.yaml: no such file or directory"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: silence ACL rule requires 'action' to be one of [allow block requireMatcher], got \"foo\""
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: invalid ACL rule, no alertmanager with name \"unknown\" found"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: invalid ACL rule, failed to parse name_re \"cluster***\": error parsing regexp: invalid nested repetition operator: `**`"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: invalid ACL rule, failed to parse value_re \"prod***\": error parsing regexp: invalid nested repetition operator: `**`"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: invalid silence ACL rule, no group with name \"unknown\" found in authorization.groups configuration"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: invalid ACL rule, failed to parse name_re \"cluster.++++\": error parsing regexp: invalid nested repetition operator: `++`"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: invalid ACL rule, failed to parse value_re \".+++\": error parsing regexp: invalid nested repetition operator: `++`"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: silence ACL rule matcher can only have 'name' or 'name_re' set, not both"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: silence ACL rule matcher can only have 'value' or 'value_re' set, not both"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: silence ACL rule filter requires 'name' or 'name_re' to be set"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: silence ACL rule filter requires 'value' or 'value_re' to be set"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: silence ACL rule matcher requires 'name' or 'name_re' to be set"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: silence ACL rule matcher requires 'name' or 'name_re' to be set"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: silence ACL rule matcher requires 'value' or 'value_re' to be set"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: silence ACL rule matcher requires 'value' or 'value_re' to be set"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: silence ACL rule requires 'reason' to be set"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: silence ACL rule filter can only have 'name' or 'name_re' set, not both"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="invalid silence ACL rule at position 0: silence ACL rule filter can only have 'value' or 'value_re' set, not both"
-- karma.yaml --

View File

@@ -7,7 +7,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=flag.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=flag proxy=false readonly=false uri=http://127.0.0.1:8080
level=info msg="Configured Alertmanager source" cluster=flag name=flag proxy=false readonly=false uri=http://127.0.0.1:8080
level=info msg="Configuration is valid"
-- flag.yaml --
alertmanager:

View File

@@ -7,7 +7,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=foo.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=cwd proxy=true readonly=false uri=http://127.0.0.1:8080
level=info msg="Configured Alertmanager source" cluster=cwd name=cwd proxy=true readonly=false uri=http://127.0.0.1:8080
level=info msg="Setting up proxy endpoints" alertmanager=cwd
level=info msg="Configuration is valid"
-- foo.yaml --

View File

@@ -7,7 +7,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=foo.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=cwd proxy=true readonly=false uri=http://127.0.0.1:8080
level=info msg="Configured Alertmanager source" cluster=cwd name=cwd proxy=true readonly=false uri=http://127.0.0.1:8080
level=info msg="Setting up proxy endpoints" alertmanager=cwd
level=info msg="Configuration is valid"
-- foo.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=cwd proxy=true readonly=false uri=http://127.0.0.1:8080
level=info msg="Configured Alertmanager source" cluster=cwd name=cwd proxy=true readonly=false uri=http://127.0.0.1:8080
level=info msg="Setting up proxy endpoints" alertmanager=cwd
level=info msg="Configuration is valid"
-- karma.yaml --

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=error msg="Execution failed" error="failed to register Alertmanager 'default' with URI 'https://127.0.0.1:9094': alertmanager upstream 'default' already exist"
-- karma.yaml --
alertmanager:

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=am1 proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=am1 name=am1 proxy=false readonly=false uri=https://127.0.0.1:9093
level=error msg="Execution failed" error="failed to register Alertmanager 'am1' with URI 'https://127.0.0.1:9094': alertmanager upstream 'am1' already exist"
-- karma.yaml --
alertmanager:

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=http://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=http://127.0.0.1:9093
level=info msg="Configuration is valid"
-- karma.yaml --
alertmanager:

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configuration is valid"
-- karma.yaml --
alertmanager:

View File

@@ -248,5 +248,5 @@ level=info msg=" alertsPerGroup: 2"
level=info msg=" collapseGroups: expanded"
level=info msg=" multiGridLabel: cluster"
level=info msg=" multiGridSortReverse: true"
level=info msg="Configured Alertmanager source" name=ro proxy=false readonly=true uri=http://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=ro name=ro proxy=false readonly=true uri=http://127.0.0.1:9093
level=info msg="Configuration is valid"

View File

@@ -285,10 +285,10 @@ level=info msg=" alertsPerGroup: 5"
level=info msg=" collapseGroups: collapsedOnMobile"
level=info msg=" multiGridLabel: severity"
level=info msg=" multiGridSortReverse: true"
level=info msg="Configured Alertmanager source" name=ha1 proxy=true readonly=false uri=http://127.0.0.1:9093
level=info msg="Configured Alertmanager source" name=ha2 proxy=false readonly=true uri=http://127.0.0.1:9094
level=info msg="Configured Alertmanager source" name=local proxy=true readonly=false uri=http://foo:xxx@127.0.0.1:9095
level=info msg="Configured Alertmanager source" name=client-auth proxy=false readonly=false uri=https://127.0.0.1:9096
level=info msg="Configured Alertmanager source" cluster=HA name=ha1 proxy=true readonly=false uri=http://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=HA name=ha2 proxy=false readonly=true uri=http://127.0.0.1:9094
level=info msg="Configured Alertmanager source" cluster=local name=local proxy=true readonly=false uri=http://foo:xxx@127.0.0.1:9095
level=info msg="Configured Alertmanager source" cluster=client-auth name=client-auth proxy=false readonly=false uri=https://127.0.0.1:9096
level=info msg="Setting up proxy endpoints" alertmanager=ha1
level=info msg="Setting up proxy endpoints" alertmanager=local
level=info msg="Configuration is valid"

View File

@@ -134,7 +134,7 @@ level=info msg=" alertsPerGroup: 5"
level=info msg=" collapseGroups: collapsedOnMobile"
level=info msg=" multiGridLabel: \"\""
level=info msg=" multiGridSortReverse: false"
level=info msg="Configured Alertmanager source" name=proxied proxy=true readonly=false uri=http://127.0.0.1
level=info msg="Configured Alertmanager source" cluster=proxied name=proxied proxy=true readonly=false uri=http://127.0.0.1
level=info msg="Setting up proxy endpoints" alertmanager=proxied
level=info msg="Configuration is valid"
-- karma.yaml --

View File

@@ -134,7 +134,7 @@ level=info msg=" alertsPerGroup: 5"
level=info msg=" collapseGroups: collapsedOnMobile"
level=info msg=" multiGridLabel: \"\""
level=info msg=" multiGridSortReverse: false"
level=info msg="Configured Alertmanager source" name=readonly proxy=false readonly=true uri=http://127.0.0.1
level=info msg="Configured Alertmanager source" cluster=readonly name=readonly proxy=false readonly=true uri=http://127.0.0.1
level=info msg="Configuration is valid"
-- karma.yaml --
alertmanager:

View File

@@ -8,17 +8,17 @@ wait
-- stderr.txt --
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=http://127.0.0.1:7069
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=http://127.0.0.1:7069
level=info msg="Writing PID file" path=karma.pid
level=info msg="Initial Alertmanager collection"
level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=default
level=info msg="GET request" timeout=40 uri=http://127.0.0.1:7069/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1:7069/metrics\": dial tcp 127.0.0.1:7069: connect: connection refused" alertmanager=default uri=http://127.0.0.1:7069
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7069/api/v2/status\": dial tcp 127.0.0.1:7069: connect: connection refused" alertmanager=default try=1/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7069/api/v2/silences\": dial tcp 127.0.0.1:7069: connect: connection refused" alertmanager=default try=1/2
level=info msg="GET request" timeout=40 uri=http://127.0.0.1:7069/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1:7069/metrics\": dial tcp 127.0.0.1:7069: connect: connection refused" alertmanager=default uri=http://127.0.0.1:7069
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7069/api/v2/status\": dial tcp 127.0.0.1:7069: connect: connection refused" alertmanager=default try=2/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7069/api/v2/silences\": dial tcp 127.0.0.1:7069: connect: connection refused" alertmanager=default try=2/2
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=info msg="Starting HTTP server" address=127.0.0.1:8069

View File

@@ -144,7 +144,7 @@ level=info msg=" alertsPerGroup: 5"
level=info msg=" collapseGroups: collapsedOnMobile"
level=info msg=" multiGridLabel: \"\""
level=info msg=" multiGridSortReverse: false"
level=info msg="Configured Alertmanager source" name=am proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=am name=am proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configuration is valid"
-- karma.yaml --
alertmanager:

View File

@@ -6,6 +6,6 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=http://127.0.0.1:7072
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=http://127.0.0.1:7072
level=info msg="Writing PID file" path=/foo/bar/karma.pid
level=error msg="Execution failed" error="failed to write a PID file: open /foo/bar/karma.pid: no such file or directory"

View File

@@ -8,17 +8,17 @@ wait
-- stderr.txt --
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=http://127.0.0.1:7073
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=http://127.0.0.1:7073
level=info msg="Writing PID file" path=karma.pid
level=info msg="Initial Alertmanager collection"
level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=default
level=info msg="GET request" timeout=40 uri=http://127.0.0.1:7073/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1:7073/metrics\": dial tcp 127.0.0.1:7073: connect: connection refused" alertmanager=default uri=http://127.0.0.1:7073
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7073/api/v2/status\": dial tcp 127.0.0.1:7073: connect: connection refused" alertmanager=default try=1/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7073/api/v2/silences\": dial tcp 127.0.0.1:7073: connect: connection refused" alertmanager=default try=1/2
level=info msg="GET request" timeout=40 uri=http://127.0.0.1:7073/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1:7073/metrics\": dial tcp 127.0.0.1:7073: connect: connection refused" alertmanager=default uri=http://127.0.0.1:7073
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7073/api/v2/status\": dial tcp 127.0.0.1:7073: connect: connection refused" alertmanager=default try=2/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7073/api/v2/silences\": dial tcp 127.0.0.1:7073: connect: connection refused" alertmanager=default try=2/2
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=info msg="Starting HTTP server" address=127.0.0.1:8073

View File

@@ -6,7 +6,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Reading silence ACL config file" path=acl.yaml
level=error msg="Execution failed" error="failed to parse silence ACL configuration file \"acl.yaml\": yaml: unmarshal errors:\n line 6: field nameFoo not found in type config.SilenceFilters"
-- karma.yaml --

View File

@@ -6,17 +6,17 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=http://foo:xxx@127.0.0.1
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=http://foo:xxx@127.0.0.1
level=info msg="Writing PID file" path=karma.pid
level=info msg="Initial Alertmanager collection"
level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=default
level=info msg="GET request" timeout=40 uri=http://foo:xxx@127.0.0.1/metrics
level=error msg="Request failed" error="Get \"http://foo:***@127.0.0.1/metrics\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default uri=http://foo:xxx@127.0.0.1
level=error msg="Collection failed" error="Get \"http://127.0.0.1/api/v2/status\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default try=1/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1/api/v2/silences\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default try=1/2
level=info msg="GET request" timeout=40 uri=http://foo:xxx@127.0.0.1/metrics
level=error msg="Request failed" error="Get \"http://foo:***@127.0.0.1/metrics\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default uri=http://foo:xxx@127.0.0.1
level=error msg="Collection failed" error="Get \"http://127.0.0.1/api/v2/status\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default try=2/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1/api/v2/silences\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default try=2/2
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=error msg="Execution failed" error="listen tcp: address 9999999: invalid port"

View File

@@ -118,17 +118,17 @@ promhttp_metric_handler_requests_total{code="500"}
promhttp_metric_handler_requests_total{code="503"}
-- stderr.txt --
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=http://127.0.0.1:7083
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=http://127.0.0.1:7083
level=info msg="Writing PID file" path=karma.pid
level=info msg="Initial Alertmanager collection"
level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=default
level=info msg="GET request" timeout=40 uri=http://127.0.0.1:7083/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1:7083/metrics\": dial tcp 127.0.0.1:7083: connect: connection refused" alertmanager=default uri=http://127.0.0.1:7083
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7083/api/v2/status\": dial tcp 127.0.0.1:7083: connect: connection refused" alertmanager=default try=1/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7083/api/v2/silences\": dial tcp 127.0.0.1:7083: connect: connection refused" alertmanager=default try=1/2
level=info msg="GET request" timeout=40 uri=http://127.0.0.1:7083/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1:7083/metrics\": dial tcp 127.0.0.1:7083: connect: connection refused" alertmanager=default uri=http://127.0.0.1:7083
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7083/api/v2/status\": dial tcp 127.0.0.1:7083: connect: connection refused" alertmanager=default try=2/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7083/api/v2/silences\": dial tcp 127.0.0.1:7083: connect: connection refused" alertmanager=default try=2/2
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=info msg="Starting HTTP server" address=127.0.0.1:8083

View File

@@ -8,17 +8,17 @@ wait
-- stderr.txt --
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=http://127.0.0.1:7085
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=http://127.0.0.1:7085
level=info msg="Writing PID file" path=karma.pid
level=info msg="Initial Alertmanager collection"
level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=default
level=info msg="GET request" timeout=40 uri=http://127.0.0.1:7085/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1:7085/metrics\": dial tcp 127.0.0.1:7085: connect: connection refused" alertmanager=default uri=http://127.0.0.1:7085
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7085/api/v2/status\": dial tcp 127.0.0.1:7085: connect: connection refused" alertmanager=default try=1/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7085/api/v2/silences\": dial tcp 127.0.0.1:7085: connect: connection refused" alertmanager=default try=1/2
level=info msg="GET request" timeout=40 uri=http://127.0.0.1:7085/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1:7085/metrics\": dial tcp 127.0.0.1:7085: connect: connection refused" alertmanager=default uri=http://127.0.0.1:7085
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7085/api/v2/status\": dial tcp 127.0.0.1:7085: connect: connection refused" alertmanager=default try=2/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7085/api/v2/silences\": dial tcp 127.0.0.1:7085: connect: connection refused" alertmanager=default try=2/2
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=info msg="Starting HTTP server" address=127.0.0.1:8085

View File

@@ -21,7 +21,7 @@ level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=local
level=info msg="GET request" timeout=10 uri=https://127.0.0.1:9093/metrics
level=error msg="Request failed" error="Get \"https://127.0.0.1:9093/metrics\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local uri=https://127.0.0.1:9093
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/status\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/silences\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=info msg="Starting HTTPS server" address=127.0.0.1:8087

View File

@@ -10,17 +10,17 @@ BAD KEY
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=local proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=local name=local proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Writing PID file" path=karma.pid
level=info msg="Initial Alertmanager collection"
level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=local
level=info msg="GET request" timeout=10 uri=https://127.0.0.1:9093/metrics
level=error msg="Request failed" error="Get \"https://127.0.0.1:9093/metrics\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local uri=https://127.0.0.1:9093
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/status\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=1/2
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/silences\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=1/2
level=info msg="GET request" timeout=10 uri=https://127.0.0.1:9093/metrics
level=error msg="Request failed" error="Get \"https://127.0.0.1:9093/metrics\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local uri=https://127.0.0.1:9093
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/status\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=2/2
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/silences\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=2/2
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=info msg="Starting HTTPS server" address=127.0.0.1:8088

View File

@@ -10,17 +10,17 @@ BAD CERT
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=local proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=local name=local proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Writing PID file" path=karma.pid
level=info msg="Initial Alertmanager collection"
level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=local
level=info msg="GET request" timeout=10 uri=https://127.0.0.1:9093/metrics
level=error msg="Request failed" error="Get \"https://127.0.0.1:9093/metrics\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local uri=https://127.0.0.1:9093
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/status\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=1/2
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/silences\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=1/2
level=info msg="GET request" timeout=10 uri=https://127.0.0.1:9093/metrics
level=error msg="Request failed" error="Get \"https://127.0.0.1:9093/metrics\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local uri=https://127.0.0.1:9093
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/status\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=2/2
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/silences\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=2/2
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=info msg="Starting HTTPS server" address=127.0.0.1:8089

View File

@@ -8,17 +8,17 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=local proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=local name=local proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Writing PID file" path=karma.pid
level=info msg="Initial Alertmanager collection"
level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=local
level=info msg="GET request" timeout=10 uri=https://127.0.0.1:9093/metrics
level=error msg="Request failed" error="Get \"https://127.0.0.1:9093/metrics\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local uri=https://127.0.0.1:9093
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/status\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=1/2
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/silences\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=1/2
level=info msg="GET request" timeout=10 uri=https://127.0.0.1:9093/metrics
level=error msg="Request failed" error="Get \"https://127.0.0.1:9093/metrics\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local uri=https://127.0.0.1:9093
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/status\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=2/2
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/silences\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=2/2
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=info msg="Starting HTTPS server" address=127.0.0.1:8090

View File

@@ -8,17 +8,17 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=local proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=local name=local proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Writing PID file" path=karma.pid
level=info msg="Initial Alertmanager collection"
level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=local
level=info msg="GET request" timeout=10 uri=https://127.0.0.1:9093/metrics
level=error msg="Request failed" error="Get \"https://127.0.0.1:9093/metrics\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local uri=https://127.0.0.1:9093
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/status\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=1/2
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/silences\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=1/2
level=info msg="GET request" timeout=10 uri=https://127.0.0.1:9093/metrics
level=error msg="Request failed" error="Get \"https://127.0.0.1:9093/metrics\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local uri=https://127.0.0.1:9093
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/status\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=2/2
level=error msg="Collection failed" error="Get \"https://127.0.0.1:9093/api/v2/silences\": dial tcp 127.0.0.1:9093: connect: connection refused" alertmanager=local try=2/2
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=info msg="Starting HTTPS server" address=127.0.0.1:8091

View File

@@ -9,7 +9,7 @@ wait
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=proxied proxy=true readonly=false uri=http://127.0.0.1:9094
level=info msg="Configured Alertmanager source" cluster=proxied name=proxied proxy=true readonly=false uri=http://127.0.0.1:9094
level=info msg="Setting up proxy endpoints" alertmanager=proxied
level=info msg="Writing PID file" path=karma.pid
level=info msg="Initial Alertmanager collection"
@@ -17,10 +17,10 @@ level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=proxied
level=info msg="GET request" timeout=40 uri=http://127.0.0.1:9094/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1:9094/metrics\": dial tcp 127.0.0.1:9094: connect: connection refused" alertmanager=proxied uri=http://127.0.0.1:9094
level=error msg="Collection failed" error="Get \"http://127.0.0.1:9094/api/v2/status\": dial tcp 127.0.0.1:9094: connect: connection refused" alertmanager=proxied try=1/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1:9094/api/v2/silences\": dial tcp 127.0.0.1:9094: connect: connection refused" alertmanager=proxied try=1/2
level=info msg="GET request" timeout=40 uri=http://127.0.0.1:9094/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1:9094/metrics\": dial tcp 127.0.0.1:9094: connect: connection refused" alertmanager=proxied uri=http://127.0.0.1:9094
level=error msg="Collection failed" error="Get \"http://127.0.0.1:9094/api/v2/status\": dial tcp 127.0.0.1:9094: connect: connection refused" alertmanager=proxied try=2/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1:9094/api/v2/silences\": dial tcp 127.0.0.1:9094: connect: connection refused" alertmanager=proxied try=2/2
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=info msg="Starting HTTP server" address=127.0.0.1:8094

View File

@@ -109,26 +109,6 @@ func metrics(w http.ResponseWriter, r *http.Request) {
`)
}
func status(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
io.WriteString(w, `
{
"cluster": {
"name": "01EB67XCFES27NAFAGSW48NAHC",
"peers": [
{
"address": "172.17.0.2:9094",
"name": "01EB67XCFES27NAFAGSW48NAHC"
}
],
"status": "ready"
},
"versionInfo": {
"version": "0.24.0"
}
}`)
}
func empty(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
io.WriteString(w, "[]")
@@ -142,7 +122,6 @@ func main() {
}
http.HandleFunc("/metrics", metrics)
http.HandleFunc("/api/v2/status", status)
http.HandleFunc("/api/v2/silences", empty)
http.HandleFunc("/api/v2/alerts/groups", empty)

View File

@@ -134,7 +134,7 @@ level=info msg=" alertsPerGroup: 5"
level=info msg=" collapseGroups: collapsedOnMobile"
level=info msg=" multiGridLabel: \"\""
level=info msg=" multiGridSortReverse: false"
level=info msg="Configured Alertmanager source" name=socks5_proxy proxy=false readonly=false uri=http://127.0.0.1
level=info msg="Configured Alertmanager source" cluster=socks5_proxy name=socks5_proxy proxy=false readonly=false uri=http://127.0.0.1
level=info msg="Configuration is valid"
-- karma.yaml --
alertmanager:

View File

@@ -4,7 +4,7 @@ exec bash -x ./test.sh &
exec bash -c 'I=0 ; while [ ! -f alertmanager.pid ] && [ $I -lt 30 ]; do sleep 1; I=$((I+1)); done'
karma.bin-should-work --pid-file=karma.pid
! stdout .
stderr 'level=info msg="Configured Alertmanager source" name=proxy-url proxy=false readonly=false uri=http://am.example.com'
stderr 'level=info msg="Configured Alertmanager source" cluster=proxy-url name=proxy-url proxy=false readonly=false uri=http://am.example.com'
stderr 'level=info msg="GET request" timeout=10 uri=http://am.example.com/metrics'
stderr 'level=info msg="Upstream version" alertmanager=proxy-url version=0.24.0'
stderr 'level=info msg="Got silences" alertmanager=proxy-url duration=.+ silences=0'
@@ -65,31 +65,6 @@ func metrics(w http.ResponseWriter, r *http.Request) {
`)
}
func status(w http.ResponseWriter, r *http.Request) {
if r.Host != "am.example.com" {
w.WriteHeader(400)
return
}
w.Header().Set("Content-Type", "application/json")
io.WriteString(w, `
{
"cluster": {
"name": "01EB67XCFES27NAFAGSW48NAHC",
"peers": [
{
"address": "172.17.0.2:9094",
"name": "01EB67XCFES27NAFAGSW48NAHC"
}
],
"status": "ready"
},
"versionInfo": {
"version": "0.24.0"
}
}`)
}
func empty(w http.ResponseWriter, r *http.Request) {
if r.Host != "am.example.com" {
w.WriteHeader(400)
@@ -108,7 +83,6 @@ func main() {
}
http.HandleFunc("/metrics", metrics)
http.HandleFunc("/api/v2/status", status)
http.HandleFunc("/api/v2/silences", empty)
http.HandleFunc("/api/v2/alerts/groups", empty)

View File

@@ -13,17 +13,17 @@ wait
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=http://127.0.0.1
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=http://127.0.0.1
level=info msg="Writing PID file" path=karma.pid
level=info msg="Initial Alertmanager collection"
level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=default
level=info msg="GET request" timeout=40 uri=http://127.0.0.1/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1/metrics\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default uri=http://127.0.0.1
level=error msg="Collection failed" error="Get \"http://127.0.0.1/api/v2/status\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default try=1/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1/api/v2/silences\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default try=1/2
level=info msg="GET request" timeout=40 uri=http://127.0.0.1/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1/metrics\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default uri=http://127.0.0.1
level=error msg="Collection failed" error="Get \"http://127.0.0.1/api/v2/status\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default try=2/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1/api/v2/silences\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default try=2/2
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=info msg="Starting HTTP server" address=127.0.0.1:8103

View File

@@ -5,7 +5,7 @@ cmp stderr stderr.txt
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=https://127.0.0.1:9093
level=info msg="Configuration is valid"
-- karma.yaml --
alertmanager:

View File

@@ -11,17 +11,17 @@ wait
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=http://127.0.0.1:7108
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=http://127.0.0.1:7108
level=info msg="Writing PID file" path=karma.pid
level=info msg="Initial Alertmanager collection"
level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=default
level=info msg="GET request" timeout=40 uri=http://127.0.0.1:7108/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1:7108/metrics\": dial tcp 127.0.0.1:7108: connect: connection refused" alertmanager=default uri=http://127.0.0.1:7108
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7108/api/v2/status\": dial tcp 127.0.0.1:7108: connect: connection refused" alertmanager=default try=1/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7108/api/v2/silences\": dial tcp 127.0.0.1:7108: connect: connection refused" alertmanager=default try=1/2
level=info msg="GET request" timeout=40 uri=http://127.0.0.1:7108/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1:7108/metrics\": dial tcp 127.0.0.1:7108: connect: connection refused" alertmanager=default uri=http://127.0.0.1:7108
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7108/api/v2/status\": dial tcp 127.0.0.1:7108: connect: connection refused" alertmanager=default try=2/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7108/api/v2/silences\": dial tcp 127.0.0.1:7108: connect: connection refused" alertmanager=default try=2/2
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=info msg="Starting HTTP server" address=127.0.0.1:8108

View File

@@ -11,17 +11,17 @@ wait
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=http://127.0.0.1
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=http://127.0.0.1
level=info msg="Writing PID file" path=karma.pid
level=info msg="Initial Alertmanager collection"
level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=default
level=info msg="GET request" timeout=40 uri=http://127.0.0.1/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1/metrics\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default uri=http://127.0.0.1
level=error msg="Collection failed" error="Get \"http://127.0.0.1/api/v2/status\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default try=1/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1/api/v2/silences\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default try=1/2
level=info msg="GET request" timeout=40 uri=http://127.0.0.1/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1/metrics\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default uri=http://127.0.0.1
level=error msg="Collection failed" error="Get \"http://127.0.0.1/api/v2/status\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default try=2/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1/api/v2/silences\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default try=2/2
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=info msg="Starting HTTP server" address=127.0.0.1:8109

View File

@@ -10,17 +10,17 @@ wait
-- stderr.txt --
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=http://127.0.0.1:7110
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=http://127.0.0.1:7110
level=info msg="Writing PID file" path=karma.pid
level=info msg="Initial Alertmanager collection"
level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=default
level=info msg="GET request" timeout=40 uri=http://127.0.0.1:7110/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1:7110/metrics\": dial tcp 127.0.0.1:7110: connect: connection refused" alertmanager=default uri=http://127.0.0.1:7110
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7110/api/v2/status\": dial tcp 127.0.0.1:7110: connect: connection refused" alertmanager=default try=1/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7110/api/v2/silences\": dial tcp 127.0.0.1:7110: connect: connection refused" alertmanager=default try=1/2
level=info msg="GET request" timeout=40 uri=http://127.0.0.1:7110/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1:7110/metrics\": dial tcp 127.0.0.1:7110: connect: connection refused" alertmanager=default uri=http://127.0.0.1:7110
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7110/api/v2/status\": dial tcp 127.0.0.1:7110: connect: connection refused" alertmanager=default try=2/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1:7110/api/v2/silences\": dial tcp 127.0.0.1:7110: connect: connection refused" alertmanager=default try=2/2
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=info msg="Starting HTTP server" address=127.0.0.1:8110

View File

@@ -11,17 +11,17 @@ wait
-- stderr.txt --
level=info msg="Reading configuration file" path=karma.yaml
level=info msg="Version: dev"
level=info msg="Configured Alertmanager source" name=default proxy=false readonly=false uri=http://127.0.0.1
level=info msg="Configured Alertmanager source" cluster=default name=default proxy=false readonly=false uri=http://127.0.0.1
level=info msg="Writing PID file" path=karma.pid
level=info msg="Initial Alertmanager collection"
level=info msg="Pulling latest alerts and silences from Alertmanager"
level=info msg="Collecting alerts and silences" alertmanager=default
level=info msg="GET request" timeout=40 uri=http://127.0.0.1/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1/metrics\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default uri=http://127.0.0.1
level=error msg="Collection failed" error="Get \"http://127.0.0.1/api/v2/status\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default try=1/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1/api/v2/silences\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default try=1/2
level=info msg="GET request" timeout=40 uri=http://127.0.0.1/metrics
level=error msg="Request failed" error="Get \"http://127.0.0.1/metrics\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default uri=http://127.0.0.1
level=error msg="Collection failed" error="Get \"http://127.0.0.1/api/v2/status\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default try=2/2
level=error msg="Collection failed" error="Get \"http://127.0.0.1/api/v2/silences\": dial tcp 127.0.0.1:80: connect: connection refused" alertmanager=default try=2/2
level=info msg="Collection completed"
level=info msg="Done, starting HTTP server"
level=info msg="Starting HTTP server" address=127.0.0.1:8111

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +0,0 @@
package alertmanager
func clusterMembersFromConfig(am *Alertmanager) []string {
members := []string{}
upstreams := GetAlertmanagers()
for _, upstream := range upstreams {
if upstream.ClusterName() == am.ClusterName() {
members = append(members, upstream.Name)
}
}
return members
}
func clusterMembersFromAPI(am *Alertmanager) []string {
return am.ClusterMemberNames()
}

View File

@@ -126,14 +126,13 @@ func DedupSilences() []models.ManagedSilence {
for _, am := range upstreams {
for id, silence := range am.Silences() {
cluster := am.ClusterName()
if _, found := silenceByCluster[cluster]; !found {
silenceByCluster[cluster] = map[string]models.Silence{}
if _, found := silenceByCluster[am.Cluster]; !found {
silenceByCluster[am.Cluster] = map[string]models.Silence{}
}
if _, ok := silenceByCluster[cluster][id]; !ok {
silenceByCluster[cluster][id] = silence
if _, ok := silenceByCluster[am.Cluster][id]; !ok {
silenceByCluster[am.Cluster][id] = silence
}
}
}

View File

@@ -2,7 +2,6 @@ package alertmanager_test
import (
"fmt"
"strings"
"testing"
"time"
@@ -34,7 +33,6 @@ func init() {
}
mock.RegisterURL(fmt.Sprintf("%s/metrics", uri), version, "metrics")
mock.RegisterURL(fmt.Sprintf("%s/api/v2/status", uri), version, "api/v2/status")
mock.RegisterURL(fmt.Sprintf("%s/api/v2/silences", uri), version, "api/v2/silences")
mock.RegisterURL(fmt.Sprintf("%s/api/v2/alerts/groups", uri), version, "api/v2/alerts/groups")
}
@@ -211,7 +209,6 @@ func TestClearData(t *testing.T) {
t.Errorf("[%s] Get %d known labels", am.Name, len(am.KnownLabels()))
}
mock.RegisterURL(fmt.Sprintf("%s/api/v2/status", uri), version, "api/v2/status")
mock.RegisterURL(fmt.Sprintf("%s/api/v2/silences", uri), version, "api/v2/silences")
_ = am.Pull(intern.New())
if am.Version() == "" {
@@ -235,9 +232,6 @@ func TestClearData(t *testing.T) {
if am.Version() == "" {
t.Errorf("[%s] Got empty version string", am.Name)
}
if !strings.HasPrefix(am.Error(), "missing cluster peers:") {
t.Errorf("[%s] Got non-empty error string: %s", am.Name, am.Error())
}
if len(am.Silences()) == 0 {
t.Errorf("[%s] Get %d silences", am.Name, len(am.Silences()))
}

View File

@@ -9,5 +9,4 @@ import (
func init() {
mapper.RegisterAlertMapper(v017.AlertMapper{})
mapper.RegisterSilenceMapper(v017.SilenceMapper{})
mapper.RegisterStatusMapper(v017.StatusMapper{})
}

View File

@@ -23,11 +23,6 @@ func TestGetAlertMapper(t *testing.T) {
if err != nil {
t.Errorf("mapper.GetSilenceMapper(%s) returned error: %s", version, err)
}
_, err = mapper.GetStatusMapper(version)
if err != nil {
t.Errorf("mapper.GetStatusMapper(%s) returned error: %s", version, err)
}
}
}
@@ -48,10 +43,5 @@ func TestGetInvalidAlertMapper(t *testing.T) {
if err == nil {
t.Errorf("mapper.GetSilenceMapper(%s) didn't return an error", version)
}
_, err = mapper.GetStatusMapper(version)
if err == nil {
t.Errorf("mapper.GetStatusMapper(%s) didn't return an error", version)
}
}
}

View File

@@ -5,7 +5,6 @@ import (
"net/http"
"net/url"
"sort"
"strings"
"sync"
"time"
@@ -14,7 +13,6 @@ import (
"github.com/prymitive/karma/internal/intern"
"github.com/prymitive/karma/internal/mapper"
"github.com/prymitive/karma/internal/models"
"github.com/prymitive/karma/internal/slices"
"github.com/prymitive/karma/internal/transform"
"github.com/prymitive/karma/internal/uri"
"github.com/prymitive/karma/internal/verprobe"
@@ -63,8 +61,6 @@ type Alertmanager struct {
knownLabels []string
lastError string
lastVersionProbe string
status models.AlertmanagerStatus
clusterName string
// metrics tracked per alertmanager instance
Metrics alertmanagerMetrics
// headers to send with each AlertManager request
@@ -109,22 +105,6 @@ func (am *Alertmanager) probeVersion() string {
return version
}
func (am *Alertmanager) fetchStatus(version string) (*models.AlertmanagerStatus, error) {
mapper, err := mapper.GetStatusMapper(version)
if err != nil {
return nil, err
}
var status models.AlertmanagerStatus
status, err = mapper.Collect(am.URI, am.HTTPHeaders, am.RequestTimeout, am.HTTPTransport)
if err != nil {
return nil, err
}
return &status, nil
}
func (am *Alertmanager) clearData() {
am.lock.Lock()
am.alertGroups = []models.AlertGroup{}
@@ -135,15 +115,6 @@ func (am *Alertmanager) clearData() {
am.lock.Unlock()
}
func (am *Alertmanager) clearStatus() {
am.lock.Lock()
am.status = models.AlertmanagerStatus{
ID: "",
PeerIDs: []string{},
}
am.lock.Unlock()
}
func (am *Alertmanager) pullSilences(version string, si *intern.Interner) error {
mapper, err := mapper.GetSilenceMapper(version)
if err != nil {
@@ -312,7 +283,7 @@ func (am *Alertmanager) pullAlerts(version string, si *intern.Interner) error {
{
Fingerprint: alert.Fingerprint,
Name: am.Name,
Cluster: am.ClusterName(),
Cluster: am.Cluster,
State: alert.State,
StartsAt: alert.StartsAt,
Source: alert.GeneratorURL,
@@ -391,18 +362,6 @@ func (am *Alertmanager) Pull(si *intern.Interner) error {
return err
}
status, err := am.fetchStatus(version)
if err != nil {
am.clearData()
am.clearStatus()
am.setError(err.Error())
am.Metrics.Errors[labelValueErrorsSilences]++
return err
}
am.lock.Lock()
am.status = *status
am.lock.Unlock()
err = am.pullSilences(version, si)
if err != nil {
am.clearData()
@@ -421,7 +380,6 @@ func (am *Alertmanager) Pull(si *intern.Interner) error {
am.lock.Lock()
am.lastError = ""
am.clusterName = ""
am.lock.Unlock()
for name, hc := range am.healthchecks {
@@ -533,26 +491,7 @@ func (am *Alertmanager) getLastError() string {
}
func (am *Alertmanager) Error() string {
lastError := am.getLastError()
if lastError != "" {
return lastError
}
configPeers := clusterMembersFromConfig(am)
apiPeers := clusterMembersFromAPI(am)
missing, _ := slices.StringSliceDiff(configPeers, apiPeers)
if len(missing) > 0 {
log.Debug().
Str("alertmanager", am.Name).
Strs("configured", configPeers).
Strs("api", apiPeers).
Strs("missing", missing).
Msg("Cluster peers mismatch")
return fmt.Sprintf("missing cluster peers: %s", strings.Join(missing, ", "))
}
return ""
return am.getLastError()
}
// SanitizedURI returns a copy of Alertmanager.URI with password replaced by
@@ -569,27 +508,10 @@ func (am *Alertmanager) Version() string {
return am.lastVersionProbe
}
// ClusterPeers returns a list of IDs of all peers this instance
// is connected to.
// IDs are the same as in Alertmanager API.
func (am *Alertmanager) ClusterPeers() []string {
am.lock.RLock()
defer am.lock.RUnlock()
return am.status.PeerIDs
}
// ClusterMemberNames returns a list of names of all Alertmanager instances
// that are in the same cluster as this instance (including self).
// Names are the same as in karma configuration.
func (am *Alertmanager) ClusterMemberNames() []string {
// copy status so we don't need to hold RLock until return
status := models.AlertmanagerStatus{}
am.lock.RLock()
status.ID = am.status.ID
copy(am.status.PeerIDs, status.PeerIDs)
am.lock.RUnlock()
members := []string{am.Name}
upstreams := GetAlertmanagers()
@@ -598,16 +520,8 @@ func (am *Alertmanager) ClusterMemberNames() []string {
if upstream.Name == am.Name {
continue
}
for _, peerID := range upstream.ClusterPeers() {
// IF
// other alertmanagers peerID is in this alertmanager cluster status
// OR
// this alertmanager peerID is in other alertmanagers cluster status
if slices.StringInSlice(status.PeerIDs, peerID) || peerID == status.ID {
if !slices.StringInSlice(members, upstream.Name) {
members = append(members, upstream.Name)
}
}
if upstream.Cluster != "" && upstream.Cluster == am.Cluster {
members = append(members, upstream.Name)
}
}
@@ -615,24 +529,6 @@ func (am *Alertmanager) ClusterMemberNames() []string {
return members
}
func (am *Alertmanager) ClusterName() string {
am.lock.RLock()
if am.clusterName != "" {
am.lock.RUnlock()
return am.clusterName
}
am.lock.RUnlock()
var clusterName string
if am.Cluster != "" {
clusterName = am.Cluster
} else {
clusterName = strings.Join(am.ClusterMemberNames(), " | ")
}
am.clusterName = clusterName
return clusterName
}
func (am *Alertmanager) IsHealthy() bool {
lastError := am.getLastError()
return lastError == ""

View File

@@ -244,15 +244,6 @@ func TestAlertmanagerPullSilencesWithInvalidVersion(t *testing.T) {
}
}
func TestAlertmanagerFetchStatusWithInvalidVersion(t *testing.T) {
zerolog.SetGlobalLevel(zerolog.PanicLevel)
am, _ := NewAlertmanager("cluster", "test", "http://localhost")
_, err := am.fetchStatus("0.0.1")
if err == nil {
t.Error("am.fetchStatus(invalid version) didn't return any error")
}
}
func TestExpiredSilences(t *testing.T) {
config.Config.Silences.Expired = time.Minute * 10
@@ -271,14 +262,6 @@ func TestExpiredSilences(t *testing.T) {
httpmock.RegisterResponder("GET", fmt.Sprintf("%s/metrics", uri),
httpmock.NewStringResponder(200, "alertmanager_build_info{version=\"0.22.1\"} 1\n"))
httpmock.RegisterResponder("GET", fmt.Sprintf("%s/api/v2/status", uri),
httpmock.NewStringResponder(200, `{
"cluster": {
"name": "BBBBBBBBBBBBBBBBBBBBBBBBBB",
"peers": [],
"status": "ready"
}
}`))
httpmock.RegisterResponder("GET", fmt.Sprintf("%s/api/v2/silences", uri),
httpmock.NewStringResponder(200, fmt.Sprintf(`[
{

View File

@@ -22,6 +22,9 @@ var upstreams = map[string]*Alertmanager{}
// NewAlertmanager creates a new Alertmanager instance
func NewAlertmanager(cluster, name, upstreamURI string, opts ...Option) (*Alertmanager, error) {
if cluster == "" {
cluster = name
}
am := &Alertmanager{
URI: upstreamURI,
ExternalURI: "",
@@ -41,7 +44,6 @@ func NewAlertmanager(cluster, name, upstreamURI string, opts ...Option) (*Alertm
labelValueErrorsSilences: 0,
},
},
status: models.AlertmanagerStatus{},
healthchecks: map[string]HealthCheck{},
}
@@ -77,6 +79,7 @@ func RegisterAlertmanager(am *Alertmanager) error {
// am.Name, uri.SanitizeURI(am.URI), am.ProxyRequests, am.ReadOnly
log.Info().
Str("name", am.Name).
Str("cluster", am.Cluster).
Str("uri", uri.SanitizeURI(am.URI)).
Bool("proxy", am.ProxyRequests).
Bool("readonly", am.ReadOnly).

View File

@@ -13,7 +13,6 @@ import (
var (
alertMappers = []AlertMapper{}
silenceMappers = []SilenceMapper{}
statusMappers = []StatusMapper{}
)
// Mapper converts Alertmanager response body and maps to karma data structures
@@ -35,12 +34,6 @@ type SilenceMapper interface {
Unmarshal([]byte) (*models.Silence, error)
}
// StatusMapper handles mapping Alertmanager status information containing cluster config
type StatusMapper interface {
Mapper
Collect(string, map[string]string, time.Duration, http.RoundTripper) (models.AlertmanagerStatus, error)
}
// RegisterAlertMapper allows to register mapper implementing alert data
// handling for specific Alertmanager versions
func RegisterAlertMapper(m AlertMapper) {
@@ -86,20 +79,3 @@ func GetSilenceMapper(version string) (SilenceMapper, error) {
}
return nil, fmt.Errorf("can't find silence mapper for Alertmanager %s", version)
}
// RegisterStatusMapper allows to register mapper implementing status data
// handling for specific Alertmanager versions
func RegisterStatusMapper(m StatusMapper) {
statusMappers = append(statusMappers, m)
}
// GetStatusMapper returns mapper for given version
func GetStatusMapper(version string) (StatusMapper, error) {
ver := latestIfEmpty(version)
for _, m := range statusMappers {
if m.IsSupported(fixSemVersion(ver)) {
return m, nil
}
}
return nil, fmt.Errorf("can't find status mapper for Alertmanager %s", version)
}

View File

@@ -94,32 +94,3 @@ func TestGetSilenceMapper(t *testing.T) {
})
}
}
func TestGetStatusMapper(t *testing.T) {
mapper.RegisterStatusMapper(v017.StatusMapper{})
for _, testCase := range testCases {
t.Run(testCase.requestedVersion, func(t *testing.T) {
hadPanic := false
defer func() {
if r := recover(); r != nil {
hadPanic = true
if hadPanic != testCase.hadPanic {
t.Errorf("[%s] expected panic=%v, got %v", testCase.requestedVersion, testCase.hadPanic, hadPanic)
}
}
}()
m, err := mapper.GetStatusMapper(testCase.requestedVersion)
if (err != nil) != testCase.hadError {
t.Errorf("[%s] expected error=%v, got %v", testCase.requestedVersion, testCase.hadError, err)
}
if hadPanic != testCase.hadPanic {
t.Errorf("[%s] expected panic=%v, got %v", testCase.requestedVersion, testCase.hadPanic, hadPanic)
}
if m == nil && !testCase.hadError && !testCase.hadPanic {
t.Errorf("[%s] got nil mapper", testCase.requestedVersion)
}
})
}
}

View File

@@ -13,7 +13,6 @@ import (
"github.com/prymitive/karma/internal/mapper"
"github.com/prymitive/karma/internal/mapper/v017/client"
"github.com/prymitive/karma/internal/mapper/v017/client/alertgroup"
"github.com/prymitive/karma/internal/mapper/v017/client/general"
"github.com/prymitive/karma/internal/mapper/v017/client/silence"
ammodels "github.com/prymitive/karma/internal/mapper/v017/models"
"github.com/prymitive/karma/internal/models"
@@ -119,22 +118,6 @@ func silences(c *client.AlertmanagerAPI, timeout time.Duration, si *intern.Inter
return ret, nil
}
func status(c *client.AlertmanagerAPI, timeout time.Duration) (models.AlertmanagerStatus, error) {
ret := models.AlertmanagerStatus{}
status, err := c.General.GetStatus(general.NewGetStatusParamsWithTimeout(timeout))
if err != nil {
return ret, err
}
ret.ID = status.Payload.Cluster.Name
for _, p := range status.Payload.Cluster.Peers {
ret.PeerIDs = append(ret.PeerIDs, *p.Name)
}
return ret, nil
}
func rewriteSilenceUsername(body []byte, username string) ([]byte, error) {
s := ammodels.PostableSilence{}
err := s.UnmarshalBinary(body)

View File

@@ -1,28 +0,0 @@
package v017
import (
"net/http"
"time"
"github.com/Masterminds/semver/v3"
"github.com/prymitive/karma/internal/mapper"
"github.com/prymitive/karma/internal/models"
)
// StatusMapper implements Alertmanager API schema
type StatusMapper struct {
mapper.StatusMapper
}
// IsSupported returns true if given version string is supported
func (s StatusMapper) IsSupported(version string) bool {
// no need to check for errors as we pass static value
versionRange, _ := semver.NewConstraint(">=0.22.0")
return versionRange.Check(semver.MustParse(version))
}
func (s StatusMapper) Collect(uri string, headers map[string]string, timeout time.Duration, httpTransport http.RoundTripper) (models.AlertmanagerStatus, error) {
c := newClient(uri, headers, httpTransport)
return status(c, timeout)
}

View File

@@ -1,24 +0,0 @@
{
"cluster": {
"name": "01F5PGZAYA2ZRMPYMCVVT4DJPF",
"peers": [
{
"address": "172.17.0.2:9094",
"name": "01F5PGZAYA2ZRMPYMCVVT4DJPF"
}
],
"status": "ready"
},
"config": {
"original": "global:\n resolve_timeout: 5m\n http_config:\n follow_redirects: true\n smtp_hello: localhost\n smtp_require_tls: true\n pagerduty_url: https://events.pagerduty.com/v2/enqueue\n opsgenie_api_url: https://api.opsgenie.com/\n wechat_api_url: https://qyapi.weixin.qq.com/cgi-bin/\n victorops_api_url: https://alert.victorops.com/integrations/generic/20131114/alert/\nroute:\n receiver: default\n group_by:\n - alertname\n continue: false\n routes:\n - receiver: by-cluster-service\n group_by:\n - alertname\n - cluster\n - service\n match_re:\n alertname: .*\n continue: true\n - receiver: by-name\n group_by:\n - alertname\n match_re:\n alertname: .*\n continue: true\n group_wait: 15s\n group_interval: 35s\n repeat_interval: 41d15h\ninhibit_rules:\n- source_match:\n severity: critical\n target_match:\n severity: warning\n equal:\n - alertname\n - cluster\n - service\nreceivers:\n- name: default\n- name: by-cluster-service\n- name: by-name\ntemplates: []\n"
},
"uptime": "2021-05-14T22:46:54.155Z",
"versionInfo": {
"branch": "HEAD",
"buildDate": "20210510-20:06:06",
"buildUser": "root@a1b306c81fae",
"goVersion": "go1.16.4",
"revision": "a2bbecc356c2e9cbef82c5f49e71105e1a4ade5c",
"version": "0.22.0-rc.1"
}
}

View File

@@ -1,24 +0,0 @@
{
"cluster": {
"name": "01F6PW72EBRCK9MH0YHQVWTBJ4",
"peers": [
{
"address": "172.17.0.2:9094",
"name": "01F6PW72EBRCK9MH0YHQVWTBJ4"
}
],
"status": "ready"
},
"config": {
"original": "global:\n resolve_timeout: 5m\n http_config:\n follow_redirects: true\n smtp_hello: localhost\n smtp_require_tls: true\n pagerduty_url: https://events.pagerduty.com/v2/enqueue\n opsgenie_api_url: https://api.opsgenie.com/\n wechat_api_url: https://qyapi.weixin.qq.com/cgi-bin/\n victorops_api_url: https://alert.victorops.com/integrations/generic/20131114/alert/\nroute:\n receiver: default\n group_by:\n - alertname\n continue: false\n routes:\n - receiver: by-cluster-service\n group_by:\n - alertname\n - cluster\n - service\n match_re:\n alertname: .*\n continue: true\n - receiver: by-name\n group_by:\n - alertname\n match_re:\n alertname: .*\n continue: true\n group_wait: 15s\n group_interval: 35s\n repeat_interval: 41d15h\ninhibit_rules:\n- source_match:\n severity: critical\n target_match:\n severity: warning\n equal:\n - alertname\n - cluster\n - service\nreceivers:\n- name: default\n- name: by-cluster-service\n- name: by-name\ntemplates: []\n"
},
"uptime": "2021-05-27T12:19:03.756Z",
"versionInfo": {
"branch": "HEAD",
"buildDate": "20210527-10:50:16",
"buildUser": "root@f02f227d5496",
"goVersion": "go1.16.4",
"revision": "d771b5332a3a2a341091cbb433738f8cfcd7e78a",
"version": "0.22.1"
}
}

View File

@@ -1,24 +0,0 @@
{
"cluster": {
"name": "01FZ0941W59G4CXE7WYPG81WSH",
"peers": [
{
"address": "172.17.0.2:9094",
"name": "01FZ0941W59G4CXE7WYPG81WSH"
}
],
"status": "ready"
},
"config": {
"original": "global:\n resolve_timeout: 5m\n http_config:\n follow_redirects: true\n smtp_hello: localhost\n smtp_require_tls: true\n pagerduty_url: https://events.pagerduty.com/v2/enqueue\n opsgenie_api_url: https://api.opsgenie.com/\n wechat_api_url: https://qyapi.weixin.qq.com/cgi-bin/\n victorops_api_url: https://alert.victorops.com/integrations/generic/20131114/alert/\nroute:\n receiver: default\n group_by:\n - alertname\n continue: false\n routes:\n - receiver: by-cluster-service\n group_by:\n - alertname\n - cluster\n - service\n match_re:\n alertname: .*\n continue: true\n - receiver: by-name\n group_by:\n - alertname\n match_re:\n alertname: .*\n continue: true\n group_wait: 15s\n group_interval: 35s\n repeat_interval: 41d15h\ninhibit_rules:\n- source_match:\n severity: critical\n target_match:\n severity: warning\n equal:\n - alertname\n - cluster\n - service\nreceivers:\n- name: default\n- name: by-cluster-service\n- name: by-name\ntemplates: []\n"
},
"uptime": "2022-03-25T10:14:30.023Z",
"versionInfo": {
"branch": "HEAD",
"buildDate": "20210825-10:50:35",
"buildUser": "root@e21a959be8d2",
"goVersion": "go1.16.7",
"revision": "61046b17771a57cfd4c4a51be370ab930a4d7d54",
"version": "0.23.0"
}
}

View File

@@ -1,24 +0,0 @@
{
"cluster": {
"name": "01FZ096BXEY0MQMBVTC5RAH17S",
"peers": [
{
"address": "172.17.0.2:9094",
"name": "01FZ096BXEY0MQMBVTC5RAH17S"
}
],
"status": "ready"
},
"config": {
"original": "global:\n resolve_timeout: 5m\n http_config:\n follow_redirects: true\n smtp_hello: localhost\n smtp_require_tls: true\n pagerduty_url: https://events.pagerduty.com/v2/enqueue\n opsgenie_api_url: https://api.opsgenie.com/\n wechat_api_url: https://qyapi.weixin.qq.com/cgi-bin/\n victorops_api_url: https://alert.victorops.com/integrations/generic/20131114/alert/\n telegram_api_url: https://api.telegram.org\nroute:\n receiver: default\n group_by:\n - alertname\n continue: false\n routes:\n - receiver: by-cluster-service\n group_by:\n - alertname\n - cluster\n - service\n match_re:\n alertname: .*\n continue: true\n - receiver: by-name\n group_by:\n - alertname\n match_re:\n alertname: .*\n continue: true\n group_wait: 15s\n group_interval: 35s\n repeat_interval: 41d15h\ninhibit_rules:\n- source_match:\n severity: critical\n target_match:\n severity: warning\n equal:\n - alertname\n - cluster\n - service\nreceivers:\n- name: default\n- name: by-cluster-service\n- name: by-name\ntemplates: []\n"
},
"uptime": "2022-03-25T10:15:45.839Z",
"versionInfo": {
"branch": "HEAD",
"buildDate": "20220325-09:33:56",
"buildUser": "root@265f14f5c6fc",
"goVersion": "go1.17.8",
"revision": "f484b17fa3c583ed1b2c8bbcec20ba1db2aa5f11",
"version": "0.24.0"
}
}

View File

@@ -1,24 +0,0 @@
{
"cluster": {
"name": "01GMZQ4MTNBV8TSKEKHNG6F9BR",
"peers": [
{
"address": "172.17.0.2:9094",
"name": "01GMZQ4MTNBV8TSKEKHNG6F9BR"
}
],
"status": "ready"
},
"config": {
"original": "global:\n resolve_timeout: 5m\n http_config:\n follow_redirects: true\n enable_http2: true\n smtp_hello: localhost\n smtp_require_tls: true\n pagerduty_url: https://events.pagerduty.com/v2/enqueue\n opsgenie_api_url: https://api.opsgenie.com/\n wechat_api_url: https://qyapi.weixin.qq.com/cgi-bin/\n victorops_api_url: https://alert.victorops.com/integrations/generic/20131114/alert/\n telegram_api_url: https://api.telegram.org\n webex_api_url: https://webexapis.com/v1/messages\nroute:\n receiver: default\n group_by:\n - alertname\n continue: false\n routes:\n - receiver: by-cluster-service\n group_by:\n - alertname\n - cluster\n - service\n match_re:\n alertname: .*\n continue: true\n - receiver: by-name\n group_by:\n - alertname\n match_re:\n alertname: .*\n continue: true\n group_wait: 15s\n group_interval: 35s\n repeat_interval: 41d15h\ninhibit_rules:\n- source_match:\n severity: critical\n target_match:\n severity: warning\n equal:\n - alertname\n - cluster\n - service\nreceivers:\n- name: default\n- name: by-cluster-service\n- name: by-name\ntemplates: []\n"
},
"uptime": "2022-12-23T14:45:35.190Z",
"versionInfo": {
"branch": "HEAD",
"buildDate": "20221222-14:48:36",
"buildUser": "root@521a2d62cff8",
"goVersion": "go1.19.4",
"revision": "258fab7cdd551f2cf251ed0348f0ad7289aee789",
"version": "0.25.0"
}
}

View File

@@ -1,24 +0,0 @@
{
"cluster": {
"name": "01H8NZK1C9VJ0G2W36YZ1C769B",
"peers": [
{
"address": "172.17.0.2:9094",
"name": "01H8NZK1C9VJ0G2W36YZ1C769B"
}
],
"status": "ready"
},
"config": {
"original": "global:\n resolve_timeout: 5m\n http_config:\n follow_redirects: true\n enable_http2: true\n smtp_hello: localhost\n smtp_require_tls: true\n pagerduty_url: https://events.pagerduty.com/v2/enqueue\n opsgenie_api_url: https://api.opsgenie.com/\n wechat_api_url: https://qyapi.weixin.qq.com/cgi-bin/\n victorops_api_url: https://alert.victorops.com/integrations/generic/20131114/alert/\n telegram_api_url: https://api.telegram.org\n webex_api_url: https://webexapis.com/v1/messages\nroute:\n receiver: default\n group_by:\n - alertname\n continue: false\n routes:\n - receiver: by-cluster-service\n group_by:\n - alertname\n - cluster\n - service\n match_re:\n alertname: .*\n continue: true\n - receiver: by-name\n group_by:\n - alertname\n match_re:\n alertname: .*\n continue: true\n group_wait: 15s\n group_interval: 35s\n repeat_interval: 41d15h\ninhibit_rules:\n- source_match:\n severity: critical\n target_match:\n severity: warning\n equal:\n - alertname\n - cluster\n - service\nreceivers:\n- name: default\n- name: by-cluster-service\n- name: by-name\ntemplates: []\n"
},
"uptime": "2023-08-25T09:14:47.562Z",
"versionInfo": {
"branch": "HEAD",
"buildDate": "20230824-11:09:02",
"buildUser": "root@520df6c16a84",
"goVersion": "go1.20.7",
"revision": "d7b4f0c7322e7151d6e3b1e31cbc15361e295d8d",
"version": "0.26.0"
}
}

View File

@@ -1,24 +0,0 @@
{
"cluster": {
"name": "01HQT3QKPPET68V7AG3NSVXA95",
"peers": [
{
"address": "172.17.0.2:9094",
"name": "01HQT3QKPPET68V7AG3NSVXA95"
}
],
"status": "ready"
},
"config": {
"original": "global:\n resolve_timeout: 5m\n http_config:\n follow_redirects: true\n enable_http2: true\n smtp_hello: localhost\n smtp_require_tls: true\n pagerduty_url: https://events.pagerduty.com/v2/enqueue\n opsgenie_api_url: https://api.opsgenie.com/\n wechat_api_url: https://qyapi.weixin.qq.com/cgi-bin/\n victorops_api_url: https://alert.victorops.com/integrations/generic/20131114/alert/\n telegram_api_url: https://api.telegram.org\n webex_api_url: https://webexapis.com/v1/messages\nroute:\n receiver: default\n group_by:\n - alertname\n continue: false\n routes:\n - receiver: by-cluster-service\n group_by:\n - alertname\n - cluster\n - service\n match_re:\n alertname: .*\n continue: true\n - receiver: by-name\n group_by:\n - alertname\n match_re:\n alertname: .*\n continue: true\n group_wait: 15s\n group_interval: 35s\n repeat_interval: 41d15h\ninhibit_rules:\n- source_match:\n severity: critical\n target_match:\n severity: warning\n equal:\n - alertname\n - cluster\n - service\nreceivers:\n- name: default\n- name: by-cluster-service\n- name: by-name\ntemplates: []\n"
},
"uptime": "2024-02-29T09:39:36.791Z",
"versionInfo": {
"branch": "HEAD",
"buildDate": "20240228-11:47:50",
"buildUser": "root@2024b1e0f6e3",
"goVersion": "go1.21.7",
"revision": "0aa3c2aad14cff039931923ab16b26b7481783b5",
"version": "0.27.0"
}
}

View File

@@ -26,7 +26,6 @@ VERSIONS := 0.22.0 022.1 0.23.0 0.24.0 0.25.0 0.26.0 0.27.0
@mkdir -p $(CURDIR)/$(VERSION)/api/v$(API) $(CURDIR)/$(VERSION)/api/v$(API)/alerts
@curl --fail -s localhost:9093/metrics > $(CURDIR)/$(VERSION)/metrics
@curl --fail -s localhost:9093/api/v$(API)/status | python3 -m json.tool > $(CURDIR)/$(VERSION)/api/v$(API)/status
@curl --fail -s localhost:9093/api/v$(API)/silences | python3 -m json.tool > $(CURDIR)/$(VERSION)/api/v$(API)/silences
@curl --fail -s localhost:9093/api/v$(API)/alerts/groups | python3 -m json.tool > $(CURDIR)/$(VERSION)/api/v$(API)/alerts/groups

View File

@@ -1,6 +0,0 @@
package models
type AlertmanagerStatus struct {
ID string
PeerIDs []string
}