{"_id":"@cinemataztic/slack-alertmanager","_rev":"3-875ea2c58a563ac2fc6604821ac4bdd4","name":"@cinemataztic/slack-alertmanager","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.2":{"name":"@cinemataztic/slack-alertmanager","version":"0.1.2","keywords":["slack","alertmanager"],"author":{"name":"Cinemataztic"},"license":"ISC","_id":"@cinemataztic/slack-alertmanager@0.1.2","maintainers":[{"name":"alkiko","email":"allan@alkiko.com"},{"name":"mikkel_cinemataztic","email":"mw@cinemataztic.com"}],"homepage":"https://github.com/cinemataztic/slack-alertmanager","bugs":{"url":"https://github.com/cinemataztic/slack-alertmanager/issues"},"dist":{"shasum":"91222286f38f55ebf7b2ae5033c41bf22e925e48","tarball":"https://registry.npmjs.org/@cinemataztic/slack-alertmanager/-/slack-alertmanager-0.1.2.tgz","fileCount":7,"integrity":"sha512-cS/Fx6dclhl+u+3dEgKP5+4GHsnvmjPGh9nqq4buqeRTw7hHTBvtacN/c7RdkQMnpxHOCqjUzaI8Q4C9Hgawow==","signatures":[{"sig":"MEQCIF7oo3nqy0cZMDIeF7Q9ISBmcK52sPG6tQ286xEGhq2vAiA7XqA80id36qf3Xt0QrvV3+Yn09MLG2pnres5Rq1pFgQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12743},"main":"src/index.js","gitHead":"aca3d425f49990fb3511d2e8fb8648e2836d7930","scripts":{"test:ci":"cross-env NODE_ENV=test jest --ignoreProjects system --detectOpenHandles --forceExit --silent=false"},"_npmUser":{"name":"alkiko","email":"allan@alkiko.com"},"repository":{"url":"git+https://github.com/cinemataztic/slack-alertmanager.git","type":"git"},"_npmVersion":"10.8.2","description":"Slack alert manager ","directories":{},"_nodeVersion":"20.19.1","dependencies":{"@slack/webhook":"^7.0.5"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","prettier":"^3.5.3","cross-env":"^7.0.3"},"_npmOperationalInternal":{"tmp":"tmp/slack-alertmanager_0.1.2_1747892561382_0.1822184678107055","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."}},"time":{"created":"2025-05-22T05:42:41.301Z","modified":"2026-05-05T12:32:47.462Z","0.1.2":"2025-05-22T05:42:41.632Z"},"bugs":{"url":"https://github.com/cinemataztic/slack-alertmanager/issues"},"author":{"name":"Cinemataztic"},"license":"ISC","homepage":"https://github.com/cinemataztic/slack-alertmanager","keywords":["slack","alertmanager"],"repository":{"url":"git+https://github.com/cinemataztic/slack-alertmanager.git","type":"git"},"description":"Slack alert manager ","maintainers":[{"name":"alkiko","email":"allan@alkiko.com"}],"readme":"# Slack AlertManager\n\nSlack AlertManager is built on [@slack-webhook](https://www.npmjs.com/package/@slack/webhook) that allows clients to send alerts to a dedicated slack channel. The Slack AlertManager has a configurable throttling feature that ensures no error messages are spammed.\n\nThe purpose of this package is to provide an application level Slack alertmanager which would help in raising alerts to i.e QA or engineering team in case something went wrong during an application's lifecycle. The package requires minimal setup and only requires the slack webhook URL to get started with this package.\n\n## Getting started\n\nThe package is available on [npm](https://www.npmjs.com/package/@cinemataztic/slack-alertmanager), and can be installed with:\n\n```sh\nnpm i @cinemataztic/slack-alertmanager\n```\n\n## Prerequisites\n\nNode.js version should be >=18.\n\n## Usage\n\nTo use the module, you must require it.\n\n```js\nconst { SlackAlertManager } = require('@cinemataztic/slack-alertmanager');\n```\n\n## Configuration\n\nConfigurations must be passed to the SlackAlertManager to initialize Slack Webhooks internally.\n\n### `config`\n\n- `slackWebhookUrl?: string`\n\n  The webhook URL from Slack which will be used for the initialization of Slack Webhooks internally. This is a required field. In order to create a webhook URL, follow the instructions in [here](https://api.slack.com/messaging/webhooks#getting_started).\n\n- `slackUsername?: string`\n\n  The name that shows up in engineering channel i.e Bob. In case no value is provided, the package sets a default name.\n\n  Default value is `default`.\n\n- `alertCooldown?: number`\n\n  The number of milliseconds for an alert cooldown for the same event alert. This ensures that messages are not spammed constantly and are throttled as per the configuration. In case no alert cooldown time in milliseconds is provided, the package sets a default alert cooldown time.\n\n  Default value is `60000`.\n\n```js\nconst slackAlertManager = new SlackAlertManager({\n  slackWebhookUrl: SLACK_WEBHOOK_URL,\n  slackUsername: 'Bob',\n  alertCooldown: 60000,\n});\n```\n\n## Indicate that the process is up and running\n\nTo indicate within the application, that a process/service is up and running, provide the names of entity and subject. Entity is the source i.e 'Producer' and subject is the process i.e in case of Producer it can be a topic.\n\nThis will set the state of entity + subject to 1 which indicates that the combination of entiy and source is in ON state. \n\nThis will only send an alert to Slack channel once the same combination had a state set to 0 an OFF state, and now has the state set to 1, on ON state. Clients can send an optional textBody in case they want to notify that a particular process/service is up and running.\n\n```js\nslackAlertManager.up('producer', 'some-topic', 'Kafka producer is running');\n```\n\n## Indicate that the process is down and is not running\n\nTo indicate within the application, that a process/service is down and is not running, provide the names of entity ,subject, and the textBody that the slack webhooks would delegate to the slack channel. Entity is the source i.e 'Consumer', subject is the process i.e in case of Consumer it can be a topic, and the textBody is a message that can have emoticons for readability.\n\nThis will set the state of entity + subject to 0 which indicates that the combination of entiy and source is in OFF state. \n\nThis will send an alert to slack channel with a delay of alert time cooldown that is configured during initialization.\n\n```js\nslackAlertManager.down('consumer', 'some-topic', 'broker transport failure');\n```\n\n## Basic Slack Alerts\n\nTo send a basic slack alert without worrying about the internal state management of the entity + entity's subject. The client can simply call the following method with a textBody.\n\n```js\nslackAlertManager.sendAlert('something happened');\n```\n\n## Clear internal states\n\nTo clear the states of the entity + entity's subject. The client can simply call the following method for clearing out all the states internally. This will reset the states of entity + entity's subject i.e no ON or OFF states for multiple combinations.\n\n```js\nslackAlertManager.clear();\n```\n\n## Motivation\n\nMany of our services are relying upon the Kafka message queue system and other external systems with a high throughput. In case something goes wrong with any service running on Node.js pertaining to Kafka, there are no early alerts and rather the monitoring team has to report about an outage regarding Kafka in affected services. Slack alertmanager at an application level was introduced to address the concerns about failures or outages happening in the background without raising an alert. \n\nWith a minimalist alertmanager package built upon [@slack-webhook](https://www.npmjs.com/package/@slack/webhook). The clients can get timely error alerts on their dedicated slack channel to mitigate the issues emanating from their applications. \n","readmeFilename":"README.md"}