{"_id":"55d3b64af77e6d0d00b1b2a1","__v":38,"category":{"_id":"55d3b645f77e6d0d00b1b276","version":"55d3b644f77e6d0d00b1b273","__v":1,"project":"55c505b41469ad2500fa2ab7","pages":["55d3b64af77e6d0d00b1b29f","55d3b64af77e6d0d00b1b2a0","55d3b64af77e6d0d00b1b2a1","55d3b64af77e6d0d00b1b2a2"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-08-10T18:44:12.108Z","from_sync":false,"order":3,"slug":"triggers","title":"Triggers"},"parentDoc":null,"user":"55c50f4a7c199a2f00665cbf","version":{"_id":"55d3b644f77e6d0d00b1b273","project":"55c505b41469ad2500fa2ab7","__v":6,"createdAt":"2015-08-18T22:48:36.632Z","releaseDate":"2015-08-18T22:48:36.632Z","categories":["55d3b645f77e6d0d00b1b274","55d3b645f77e6d0d00b1b275","55d3b645f77e6d0d00b1b276","55d3b645f77e6d0d00b1b277","55d3b645f77e6d0d00b1b278","55d3b645f77e6d0d00b1b279","55d3b645f77e6d0d00b1b27a","55d3b645f77e6d0d00b1b27b","55d3b645f77e6d0d00b1b27c","55d3b645f77e6d0d00b1b27d","55d7c2939510f00d007ec6fe","56fac9925df15a20002972a2","56fb2f7668e1d30e00a0b672","583498d411e8af2500f6b334","58e52a180ab7b03b00f4a97a"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"1.1.0","version":"1.1"},"project":"55c505b41469ad2500fa2ab7","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-08-10T23:08:00.609Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"By selecting Webhook as a trigger when creating a rule, you get a unique Neptuneio endpoint as webhook. It can be called from any monitoring tool or manually from a command-line. This is especially useful in the following cases :\n\n1.  Neptune doesn't support a direct integration with your existing monitoring, but you still want to use Neptune. You simply add the unique webhook to your alert in the monitoring tool. Whenever the alert triggers, the webhook will be triggered and so does the corresponding rule in Neptune\n\n2. You defined a complex set of actions to run on a cluster of servers that you want to trigger programatically. Now by calling a simple webhook programmatically, you will be able to execute the entire set of defined actions\n\n## Webhook JSON payload : \nYou can optionally send a JSON as webhook payload. The key value pairs from the posted `JSON` will be available as environment variables in your runbook. You can access them as `$Key1` and `$Key2` as you do in any normal shell script.\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -H \\\"Content-type: application/json\\\" -X POST \\\\\\n\\\"https://www.neptune.io/api/v1/trigger/channel/webhook/3052123476f74f5db8f50d6708528d88/ad6b4320-f758-4d61-a05d-93ee92d77799\\\" \\\\\\n-d '{\\n  \\\"HostName\\\"  : <HOST>,\\n  \\\"AppName\\\"   : <APP_NAME>,\\n  \\\"AlarmName\\\" : <ALARM_NAME>,\\n  \\\"Severity\\\"  : <SEVERITY>,\\n  \\\"Source\\\"    : <SOURCE>,\\n  \\\"Act\\\"       : true,\\n  \\\"MetaData\\\"  : {\\n    \\\"Key1\\\" : \\\"Value1\\\",\\n    \\\"Key2\\\" : \\\"Value2\\\"\\n  }\\n}' \",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\nFollow these steps to create a webhook rule\n\n## Step 1: Select \"webhook\" as your trigger while creating a rule\n 1. In the create rule page, simply select webhook as your trigger. \n 2. Modify flapping protection settings if required\n## Step 2: Configure an Action in Action Details\n 1. Select the infrastructure type that you want to act on. (eg: AWS_EC2, On_Premise)\n 2. Action target where you want the action to be taken. \n    When a webhook is triggered:\n    Trigger Host -> Runs the action on a host that you pass in the webhook json.\n    Specific host -> Runs the action on a specific host that you select\n    Specific Tags -> Runs the action on all the hosts in the tags that you select\n    CLI Machine -> Runs a CLI runbook on Neptune. You can use this for running AWS, Heroku cli scripts automatically. \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/954i1CvxQ4W7z6gvMz7t_webhooks-trigger.png\",\n        \"webhooks-trigger.png\",\n        \"1554\",\n        \"965\",\n        \"#7d174a\",\n        \"\"\n      ],\n      \"caption\": \"Webhook Rule creation.\"\n    }\n  ]\n}\n[/block]\n  \n* Step 3: Edit and save the runbook if required.\n* Step 4: Press the create rule button\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/BHMz8ISTQ1KcBlROSdmQ_webhooks-action.png\",\n        \"webhooks-action.png\",\n        \"1554\",\n        \"965\",\n        \"#759e9c\",\n        \"\"\n      ],\n      \"caption\": \"Webhook Rule creation.\"\n    }\n  ]\n}\n[/block]\nCongratulations ! Now, you will be able to trigger the rule from anywhere by simply calling the endpoint. View rule page has a sample curl query which can be used to trigger this Webhook rule.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/etoSbx9sR9KCa9AxTPgY_webhooks-query.png\",\n        \"webhooks-query.png\",\n        \"1554\",\n        \"965\",\n        \"#7d194b\",\n        \"\"\n      ],\n      \"caption\": \"Getting the webhook rule endpoint from view rule page.\"\n    }\n  ]\n}\n[/block]\n\n\nThe keys present in the posted metadata will be available in the runbook as environment variables and you can access them as `$Key1` and `$Key2` in the runbook.","excerpt":"","slug":"webhook-triggers","type":"basic","title":"Webhook Triggers"}
By selecting Webhook as a trigger when creating a rule, you get a unique Neptuneio endpoint as webhook. It can be called from any monitoring tool or manually from a command-line. This is especially useful in the following cases : 1. Neptune doesn't support a direct integration with your existing monitoring, but you still want to use Neptune. You simply add the unique webhook to your alert in the monitoring tool. Whenever the alert triggers, the webhook will be triggered and so does the corresponding rule in Neptune 2. You defined a complex set of actions to run on a cluster of servers that you want to trigger programatically. Now by calling a simple webhook programmatically, you will be able to execute the entire set of defined actions ## Webhook JSON payload : You can optionally send a JSON as webhook payload. The key value pairs from the posted `JSON` will be available as environment variables in your runbook. You can access them as `$Key1` and `$Key2` as you do in any normal shell script. [block:code] { "codes": [ { "code": "curl -H \"Content-type: application/json\" -X POST \\\n\"https://www.neptune.io/api/v1/trigger/channel/webhook/3052123476f74f5db8f50d6708528d88/ad6b4320-f758-4d61-a05d-93ee92d77799\" \\\n-d '{\n \"HostName\" : <HOST>,\n \"AppName\" : <APP_NAME>,\n \"AlarmName\" : <ALARM_NAME>,\n \"Severity\" : <SEVERITY>,\n \"Source\" : <SOURCE>,\n \"Act\" : true,\n \"MetaData\" : {\n \"Key1\" : \"Value1\",\n \"Key2\" : \"Value2\"\n }\n}' ", "language": "shell" } ] } [/block] Follow these steps to create a webhook rule ## Step 1: Select "webhook" as your trigger while creating a rule 1. In the create rule page, simply select webhook as your trigger. 2. Modify flapping protection settings if required ## Step 2: Configure an Action in Action Details 1. Select the infrastructure type that you want to act on. (eg: AWS_EC2, On_Premise) 2. Action target where you want the action to be taken. When a webhook is triggered: Trigger Host -> Runs the action on a host that you pass in the webhook json. Specific host -> Runs the action on a specific host that you select Specific Tags -> Runs the action on all the hosts in the tags that you select CLI Machine -> Runs a CLI runbook on Neptune. You can use this for running AWS, Heroku cli scripts automatically. [block:image] { "images": [ { "image": [ "https://files.readme.io/954i1CvxQ4W7z6gvMz7t_webhooks-trigger.png", "webhooks-trigger.png", "1554", "965", "#7d174a", "" ], "caption": "Webhook Rule creation." } ] } [/block] * Step 3: Edit and save the runbook if required. * Step 4: Press the create rule button [block:image] { "images": [ { "image": [ "https://files.readme.io/BHMz8ISTQ1KcBlROSdmQ_webhooks-action.png", "webhooks-action.png", "1554", "965", "#759e9c", "" ], "caption": "Webhook Rule creation." } ] } [/block] Congratulations ! Now, you will be able to trigger the rule from anywhere by simply calling the endpoint. View rule page has a sample curl query which can be used to trigger this Webhook rule. [block:image] { "images": [ { "image": [ "https://files.readme.io/etoSbx9sR9KCa9AxTPgY_webhooks-query.png", "webhooks-query.png", "1554", "965", "#7d194b", "" ], "caption": "Getting the webhook rule endpoint from view rule page." } ] } [/block] The keys present in the posted metadata will be available in the runbook as environment variables and you can access them as `$Key1` and `$Key2` in the runbook.