{"id":18293094,"url":"https://github.com/kubesphere/alertmanager-kit","last_synced_at":"2025-04-05T11:30:47.584Z","repository":{"id":57520221,"uuid":"250449616","full_name":"kubesphere/alertmanager-kit","owner":"kubesphere","description":"alertmanager-kit encapsulates the interface to alertmanager in a neat way.","archived":false,"fork":false,"pushed_at":"2023-11-08T08:08:48.000Z","size":36,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-13T21:43:07.233Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kubesphere.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-03-27T05:36:34.000Z","updated_at":"2023-11-08T08:08:52.000Z","dependencies_parsed_at":"2024-03-25T18:23:05.104Z","dependency_job_id":"aa14be63-e52e-4060-bd33-a873bbcf0b51","html_url":"https://github.com/kubesphere/alertmanager-kit","commit_stats":{"total_commits":4,"total_committers":2,"mean_commits":2.0,"dds":0.25,"last_synced_commit":"28b83842d8fcb23cd31810ff39c63565678a6dab"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubesphere%2Falertmanager-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubesphere%2Falertmanager-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubesphere%2Falertmanager-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubesphere%2Falertmanager-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kubesphere","download_url":"https://codeload.github.com/kubesphere/alertmanager-kit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247330420,"owners_count":20921627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T14:21:56.897Z","updated_at":"2025-04-05T11:30:47.365Z","avatar_url":"https://github.com/kubesphere.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# alertmanager-kit\nalertmanager-kit encapsulates the interface to alertmanager in a neat way.\n\n# compatibility\nIt currently only works on newer versions of alertmanager which provide v2 api.\n\n# usage\nThe following example demonstrates an usual usage. It fetches the Alertmanager status from the service, post/get alerts, post/get/delete silence.\n```go\n// Init the config\n//config := kit.ClientConfig{\n//\tURL: \"http://139.198.112.79:59093\",\n//}\n// Use this if running on kubernetes\nconfig := kit.ClientConfig{\n    Service: \u0026kit.ServiceReference{\n        Namespace: \"monitoring\",\n        Name: \"alertmanager\",\n    },\n}\n\n// Create client for alertmanager service\nclient, e := kit.NewClient(config)\nif e != nil {\n    panic(e)\n}\nctx, _ := context.WithTimeout(context.Background(), time.Second*10)\n\n// Get status\nstatus, e := client.GetStatus(ctx)\nprettyPrintlnOrPanic(status, e)\n\n// Post alerts\ne = client.PostAlerts(ctx, []*kit.RawAlert{{\n    Labels:      map[string]string{\n        \"alertname\": \"test\",\n        \"alerttype\": \"test\",\n        \"namespace\": \"test\",\n        \"pod\": \"test\"},\n    Annotations: map[string]string{\"message\": \"test\"},\n}})\nprettyPrintlnOrPanic(nil, e)\n\n// Get alerts\nalerts, e := client.GetAlerts(ctx,\n    kit.NewAlertsFilter().WithFilter([]string{\"alertname=\\\"test\\\"\"}))\nprettyPrintlnOrPanic(alerts, e)\n\n// Post silence\nsilenceId, e := client.PostSilence(ctx, \u0026kit.RawSilence{\n    StartsAt: strfmt.DateTime(time.Now()),\n    EndsAt: strfmt.DateTime(time.Now().Add(time.Minute)),\n    CreatedBy: \"test\",\n    Matchers: []*kit.Matcher{{\n        Name: \"alertname\",\n        Value: \"test\",\n    }},\n})\nprettyPrintlnOrPanic(silenceId, e)\n\n// Get silence\nsilence, e := client.GetSilence(ctx, silenceId)\nprettyPrintlnOrPanic(silence, e)\n\n// Delete silence\ne = client.DeleteSilence(ctx, silenceId)\nprettyPrintlnOrPanic(nil, e)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkubesphere%2Falertmanager-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkubesphere%2Falertmanager-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkubesphere%2Falertmanager-kit/lists"}