{"id":15714366,"url":"https://github.com/fgouteroux/slam","last_synced_at":"2025-03-30T19:46:55.398Z","repository":{"id":244820301,"uuid":"816362027","full_name":"fgouteroux/slam","owner":"fgouteroux","description":"Send slack messages from alertmanager webhook receiver.","archived":false,"fork":false,"pushed_at":"2025-01-20T16:13:16.000Z","size":76,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-05T22:36:56.690Z","etag":null,"topics":["alertmanager","prometheus","slack"],"latest_commit_sha":null,"homepage":"","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/fgouteroux.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,"publiccode":null,"codemeta":null}},"created_at":"2024-06-17T15:33:17.000Z","updated_at":"2025-01-20T16:11:41.000Z","dependencies_parsed_at":"2024-06-17T17:52:30.620Z","dependency_job_id":"11c888fb-a342-454b-83c9-dafff4abc72c","html_url":"https://github.com/fgouteroux/slam","commit_stats":null,"previous_names":["fgouteroux/slam"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgouteroux%2Fslam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgouteroux%2Fslam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgouteroux%2Fslam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgouteroux%2Fslam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fgouteroux","download_url":"https://codeload.github.com/fgouteroux/slam/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246372503,"owners_count":20766626,"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":["alertmanager","prometheus","slack"],"created_at":"2024-10-03T21:36:22.671Z","updated_at":"2025-03-30T19:46:55.376Z","avatar_url":"https://github.com/fgouteroux.png","language":"Go","readme":"# slam\nSend alertmanager alerts notifications to slack without creating webhook url for each slack channel.\n\nIt update the original slack channel message to avoid searching if an alert is resolved or not.\n\n![](examples/slam.gif)\n\n## usage\n\n```\nUsage of slam:\n  -cache string\n      Cache type (local or redis) (default \"local\")\n  -cache.redis.db int\n      Redis DB\n  -cache.redis.host string\n      Redis host (default \"localhost:6379\")\n  -cache.redis.key-ttl int\n      Redis key ttl in seconds (default 1296000)\n  -debug\n      Enable debug mode\n  -server.grace-timeout int\n       Grace timeout for shutdown HTTP server (default 5)\n  -server.http-idle-timeout int\n       Idle timeout for HTTP server (default 30)\n  -server.http-listen-address string\n       Listen address for HTTP server\n  -server.http-listen-port int\n       Listen address for HTTP server (default 8080)\n  -server.http-read-timeout int\n      Read timeout for HTTP server (default 30)\n  -server.http-write-timeout int\n      Write timeout for HTTP server (default 30)\n  -server.tls-cert-path string\n      TLS certificate path for HTTP server\n  -server.tls-key-path string\n      TLS key path for HTTP server\n  -slack-msg-length-limit int\n      Slack message length limit before truncate. (default 1000)\n  -slack-token string\n      Slack app token (could be set by SLACK_TOKEN env var)\n  -template-files string\n      Template files to load (files identified by the pattern, like *.tmpl)\n  -template.annotation.title string\n      Annotation key name to get for setting slack title message (default \"summary\")\n  -template.annotation.title-link string\n      Annotation key name to get for setting slack title link message (default \"title_link\")\n  -version\n      show version\n```\n\n## How it's works\n\nslam use the webhook config from alertmanager: https://prometheus.io/docs/alerting/latest/configuration/#webhook_config\n\nslam use the `groupKey` from webhook json payload, to identify if:\n* the slack message has already been sent (for firing status)\n* the original slack message should be updated (for resolved status)\n\nThis key is stored in local memory or redis.\n\nIf the key is not found, it send a new message in the slack channel.\n\n\n## Template\n\nAs using webhook format, there is no templating from alertmanager. So we enable the template feature in slam to allow formating slack message. By default, we apply a simple slack message format (cf gif image)\n\nIt's possible to define different template and to choose it in the query url.\n\nRun slam with template location:\n```\nslam -template-files examples/*.tmpl\n```\n\nSend an alert and use slack.tmpl file template:\n```\ncurl \"http://localhost:8080/webhook/mychann?template=slack.tmpl\" -X POST -H \"Content-type: application/json\" -d @payload.json\n```\n\n## Setup alertmanager with slam (using webhook receiver)\n\n```\nglobal:\n  resolve_timeout: 5m\nroute:\n  receiver: webhook_receiver\nreceivers:\n  - name: webhook_receiver\n    webhook_configs:\n      - url: http://localhost:8080/webhook/mychann\n        send_resolved: true\n```\n\n## Prometheus metrics\n\nslam expose standard prometheus metrics on `/metrics` endpoint.\n\n```\n# HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served.\n# TYPE promhttp_metric_handler_requests_in_flight gauge\npromhttp_metric_handler_requests_in_flight 1\n# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.\n# TYPE promhttp_metric_handler_requests_total counter\npromhttp_metric_handler_requests_total{code=\"200\"} 0\npromhttp_metric_handler_requests_total{code=\"500\"} 0\npromhttp_metric_handler_requests_total{code=\"503\"} 0\n# HELP slam_message_sent_failed_total The total number of failed messages sent.\n# TYPE slam_message_sent_failed_total counter\nslam_message_sent_failed_total{channel=\"testfgx2\"} 1\n# HELP slam_message_sent_total The total number of successfully messages sent.\n# TYPE slam_message_sent_total counter\nslam_message_sent_total{channel=\"testfgx\"} 1\n```\n\n## Endpoints\n\n### Webhook API\n\nSend slack message in a given channel\n```\nGET /webhook/\u003cchannel\u003e\n```\nStatus code: 200 if message sent.\n\nResponse: ok\n\n\n### Ready / health API\n\nReadiness check (check slack authentication)\n```\nGET /ready\n```\nStatus code: 200 if ready.\n\nResponse: OK\n\nHealthiness check\n```\nGET /health\n```\nStatus code: 200 if healthy.\n\nResponse: OK\n\n## Limitations\n\nIf the webhook payload contains several alerts, it will wait that all alerts be resolved before update the original message.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffgouteroux%2Fslam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffgouteroux%2Fslam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffgouteroux%2Fslam/lists"}