{"id":24653861,"url":"https://github.com/joshbeard/sensu-slack-compact-alert","last_synced_at":"2026-04-30T07:42:40.472Z","repository":{"id":50472337,"uuid":"461705705","full_name":"joshbeard/sensu-slack-compact-alert","owner":"joshbeard","description":"A Sensu Go handler for sending compact alerts to Slack","archived":false,"fork":false,"pushed_at":"2023-12-06T13:07:54.000Z","size":172,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-06T00:39:24.860Z","etag":null,"topics":["python","sensu","sensu-handler","sensu-plugins","slack"],"latest_commit_sha":null,"homepage":"https://bonsai.sensu.io/assets/joshbeard/sensu-slack-compact-alert","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joshbeard.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-21T04:35:13.000Z","updated_at":"2022-03-18T06:07:44.000Z","dependencies_parsed_at":"2022-08-20T02:41:17.848Z","dependency_job_id":null,"html_url":"https://github.com/joshbeard/sensu-slack-compact-alert","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/joshbeard/sensu-slack-compact-alert","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshbeard%2Fsensu-slack-compact-alert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshbeard%2Fsensu-slack-compact-alert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshbeard%2Fsensu-slack-compact-alert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshbeard%2Fsensu-slack-compact-alert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joshbeard","download_url":"https://codeload.github.com/joshbeard/sensu-slack-compact-alert/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshbeard%2Fsensu-slack-compact-alert/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259589294,"owners_count":22880945,"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":["python","sensu","sensu-handler","sensu-plugins","slack"],"created_at":"2025-01-25T21:14:19.537Z","updated_at":"2026-04-30T07:42:35.444Z","avatar_url":"https://github.com/joshbeard.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Compact Sensu Slack Handler\n\n[![Package Sensu Asset](https://github.com/joshbeard/sensu-slack-compact-alert/actions/workflows/build.yml/badge.svg)](https://github.com/joshbeard/sensu-slack-compact-alert/actions/workflows/build.yml)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/d9a7e0288838460096f3f9794dc5a06b)](https://www.codacy.com/gh/joshbeard/sensu-slack-compact-alert/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=joshbeard/sensu-slack-compact-alert\u0026amp;utm_campaign=Badge_Grade)\n[![CodeFactor](https://www.codefactor.io/repository/github/joshbeard/sensu-slack-compact-alert/badge)](https://www.codefactor.io/repository/github/joshbeard/sensu-slack-compact-alert)\n[![DeepSource](https://deepsource.io/gh/joshbeard/sensu-slack-compact-alert.svg/?label=active+issues\u0026token=6AD0pzfy46588O144L_mFJaP)](https://deepsource.io/gh/joshbeard/sensu-slack-compact-alert/?ref=repository-badge)\n![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/joshbeard/sensu-slack-compact-alert)\n\nThis is a [Sensu handler](https://docs.sensu.io/sensu-go/latest/observability-pipeline/observe-process/handlers/) for sending messages to Slack.\n\nIt's written in Python and uses the [jspaleta/sensu-python-runtime](https://bonsai.sensu.io/assets/jspaleta/sensu-python-runtime) runtime in Sensu Go.\n\nSensu [provides](https://bonsai.sensu.io/assets/sensu/sensu-slack-handler) a Slack handler, but its messages take up too much space. This handler intends to be more condensed and fit messages on a single line.\n\nEmojis are used to indicate the status:\n\n![Screenshot showing Slack output](https://raw.githubusercontent.com/joshbeard/sensu-slack-compact-alert/master/docs/screenshot1.png)\n\nOptionally, checks that have a URL in its command can provide a link in the\nSlack message:\n\n![Screenshot showing link to url in check command](https://raw.githubusercontent.com/joshbeard/sensu-slack-compact-alert/master/docs/screenshot2.png)\n\n## Usage\n\nProvide a Sensu handler configuration, listing `joshbeard/sensu-slack-compact-alert` and [`jspaleta/sensu-python-runtime`](https://bonsai.sensu.io/assets/jspaleta/sensu-python-runtime) as runtime assets:\n\n```yaml\ntype: Handler\napi_version: core/v2\nmetadata:\n  name: slack\nspec:\n  runtime_assets:\n    - joshbeard/sensu-slack-compact-alert\n    - jspaleta/sensu-python-runtime\n  command: slack.py\n  env_vars:\n    - SLACK_WEBHOOK_URL=https://hooks.slack.com/services/TXXXXXXXXX6/BXXXXXXXE/PXXXXXXXXXXXXXXXXXXXXXZH\n    - SENSU_BASE_URL=https://sensu.foo.com\n  filters:\n    - is_incident\n    - not_silenced\n    - not_flapping\n    - fatigue_check\n  type: pipe\n```\n\nSee the [example handler config](https://github.com/joshbeard/sensu-slack-compact-alert/tree/master/example/handler-slack.yml).\n\nThis uses the deprecated Slack incoming webhooks because it makes it easy to\nsend notices to any (private or open) channel specified without having to run a\nbot or join channels.\n\n### Environment variables\n\nEnvironment variables can be set for certain configurations, including in a check configuration.\n\n* `SLACK_WEBHOOK_URL`: A legacy Slack webhook URL\n\n* `SLACK_USERNAME`: The username to send the message as\n\n* `SLACK_CHANNEL`:  The Slack channel to send to or a fallback channel.\n  [Labels and annotations](#labels-and-annotations) take precedence.\n\n* `ICON_URL`: A URL to an icon image to use for the Slack user\n\n* `SENSU_BASE_URL`:  The base URL to the Sensu dashboard to link to. E.g.\n  https://sensu.foo.org\n\n### Labels and Annotations\n\n* `slack_link_command_url`: Toggles linking to a URL found in the check command.\n\n* `slack_link_command_text`: The link title when using `slack_link_command_url`. By default,\n  this is \"(view site)\"\n\nSlack channels can be configured using a label or annotation.  In order of precedence:\n\n* `slack_channel`: annotation on entity\n* `slack-channel`: annotation on entity\n* `slack_channel`: label on entity\n* `slack-channel`: label on entity\n\n## Building\n\nThe [`src/`](src) directory structure is setup for Sensu to function properly. This is done according to the [sensu-python-runtime example](https://github.com/jspaleta/sensu-python-runtime).\n\nThe dependencies are installed to a `lib/` sub-directory via `pip install -r requirements.txt --target lib`. The entire directory is then compressed and uploaded to Artifactory.\n\n```shell\ncd src\npip install -r requirements.txt --target lib\ntar -cvzf ../sensu-slack-alert.tar.gz .\nshasum -a 512 sensu-slack-alert.tar.gz\n```\n\nNOTE: This uses the legacy [Slack webhooks](https://api.slack.com/legacy/custom-integrations)\nbecause it's much simpler and possible to send messages to any channel, including private ones.\n\n## Resources\n\n[Token substitution](https://docs.sensu.io/sensu-go/latest/observability-pipeline/observe-schedule/checks/#check-token-substitution) is not available in handler configurations due to security concerns (e.g. having a generic web check with the url as\na variable set by an annotation or label), which is why this handler parses those annotations and labels directly.\n\nSee \u003chttps://github.com/sensu/sensu-go/issues/2528\u003e for more information.\n\n## Authors\n\n* [Josh Beard](https://joshbeard.me)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshbeard%2Fsensu-slack-compact-alert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshbeard%2Fsensu-slack-compact-alert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshbeard%2Fsensu-slack-compact-alert/lists"}