{"id":390,"date":"2016-01-20T17:59:06","date_gmt":"2016-01-20T17:59:06","guid":{"rendered":"https:\/\/defragged.org\/ossec\/?p=390"},"modified":"2020-07-03T18:19:24","modified_gmt":"2020-07-03T18:19:24","slug":"ossec-integrates-slack-and-pagerduty","status":"publish","type":"post","link":"https:\/\/defragged.org\/ossec\/2016\/01\/ossec-integrates-slack-and-pagerduty\/","title":{"rendered":"OSSEC Integrates Slack and PagerDuty"},"content":{"rendered":"\n<p>One of the new features that we open sourced and pushed to OSSEC is an \u201cintegrator\u201d daemon that we have been using internally to connect OSSEC to external APIs and alerting tools. The first two APIs we officially added were for Slack and PagerDuty.<\/p>\n\n\n\n<p>To get started, you have to download OSSEC from our fork, either from the&nbsp;<a href=\"https:\/\/bitbucket.org\/dcid\/ossec-hids\/get\/tip.tar.gz\">development branch<\/a>&nbsp;or from the our&nbsp;<a href=\"https:\/\/bitbucket.org\/dcid\/ossec-hids\/get\/v2015-12.tar.gz\">stable<\/a>&nbsp;branch:<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>After you install (or update) OSSEC, you need to enable the&nbsp;<em>integrator<\/em>&nbsp;daemon with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \/var\/ossec\/bin\/ossec-control enable integrator<\/pre>\n\n\n\n<p>If the right version of OSSEC is installed, no errors will be generated and you are ready to configure it.<\/p>\n\n\n\n<h5>Integrating with Slack<\/h5>\n\n\n\n<p>Slack is taking the world by storm and many companies are using it&nbsp;for internal communication. Most people are always connected to it, making it more practical to use for real-time alerts than to depend solely on email.<\/p>\n\n\n\n<p>Additionally, Slack integration is very easy to configure. First, you have to go to Slack and enable a new integration under&nbsp;<strong>Settings &gt; Custom Integrations &gt; Incoming Webhooks<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/blog.sucuri.net\/wp-content\/uploads\/2016\/01\/Screen-Shot-2016-01-15-at-2.17.48-AM-600x171.png\" alt=\"Screen Shot 2016-01-15 at 2.17.48 AM\" class=\"wp-image-14529\"\/><\/figure>\n\n\n\n<p>You then choose a channel and a new hook will be created in the format of:<br><code>https:\/\/hooks.slack.com\/services\/RANDOMSTRING\/RANDOMSTRING<\/code>.<\/p>\n\n\n\n<p>Save that URL and add it in with the following to your&nbsp;<strong>ossec.conf<\/strong>&nbsp;file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;integration&gt;\n&lt;name&gt;slack&lt;\/name&gt;\n&lt;level&gt;10&lt;\/level&gt;\n&lt;hook_url&gt;https:\/\/hooks.slack.com\/services\/RANDOM\/RANDOM&lt;\/hook_url&gt;\n&lt;\/integration&gt;<\/pre>\n\n\n\n<p>Once you restart OSSEC, it will force all alerts with level above 10 to go to the OSSEC room you chose before, just like this:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/blog.sucuri.net\/wp-content\/uploads\/2016\/01\/ossec-slack-integration.png\"><img src=\"https:\/\/blog.sucuri.net\/wp-content\/uploads\/2016\/01\/ossec-slack-integration.png\" alt=\"ossec-slack-integration\" class=\"wp-image-14594\"\/><\/a><\/figure><\/div>\n\n\n\n<p>You can also specify per alert category or rule id, by using the &lt;group&gt; or &lt;rule_id&gt; entries. So if you only want to receive all&nbsp;<em>authentication<\/em>&nbsp;related alerts via slack, you can add the following to your config:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;integration&gt;\n&lt;name&gt;slack&lt;\/name&gt;\n&lt;group&gt;authentication&lt;\/group&gt;\n&lt;hook_url&gt;https:\/\/hooks.slack.com\/services\/RANDOM\/RANDOM&lt;\/hook_url&gt;\n&lt;\/integration&gt;<\/pre>\n\n\n\n<p>Restart OSSEC and you are done.<\/p>\n\n\n\n<h5>Integrating with PagerDuty<\/h5>\n\n\n\n<p>PagerDuty is one of the best products out there to manage and notify network and security administrators (DevOps\/SecOps) about issues that deserve immediate attention.<\/p>\n\n\n\n<p>It is a powerful tool and one that can now be integrated with OSSEC. Be careful not to overdo it with this one. Only push to PagerDuty events that really matter.<\/p>\n\n\n\n<p>For example, we have some rules that are categorized as \u201c<strong>immediate_response_required<\/strong>\u201d as they tend to be related to service availability; either a&nbsp;service went down or the system is running out of memory. An example would be the Nginx rule 31321 and the Syslog rule 1007:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;rule id=\"31321\" level=\"5\" ignore=\"60\"&gt;\n&lt;if_sid&gt;31303&lt;\/if_sid&gt;\n&lt;match&gt;(99: Cannot assign requested address&lt;\/match&gt;\n&lt;description&gt;Nginx connection error - Out of sockets available.&lt;\/description&gt;\n&lt;group&gt;immediate_response_required,service_availability,&lt;\/group&gt;\n&lt;\/rule&gt;\n\n&lt;rule id=\"1007\" level=\"7\"&gt;\n&lt;match&gt;file system full|No space left on device&lt;\/match&gt;\n&lt;description&gt;File system full.&lt;\/description&gt;\n&lt;group&gt;immediate_response_requird,low_diskspace,&lt;\/group&gt;\n&lt;\/rule&gt;<\/pre>\n\n\n\n<p>As you can see, this triggers an alert if Nginx is unable to assign an address (likely down) or if a log file is generating an warning about no space left. These are generally pretty serious as they affect the availability of the server. So they can be a good one to push straight to Pagerduty for immediate attention.<\/p>\n\n\n\n<p>To do that, you first need to get your API key from the Pagerduty site. Go to&nbsp;<strong>Configuration &gt; Services<\/strong>&nbsp;and view the service you have your escalations integrated with. There, you will see the API key to use, like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Integration Type Generic API View PagerDuty API documentation\nIntegration Key RANDONKEY<\/pre>\n\n\n\n<p>Save the integration key and copy to the ossec.conf:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;integration&gt;\n&lt;name&gt;pagerduty&lt;\/name&gt;\n&lt;group&gt;immediate_response&lt;\/group&gt;\n&lt;api_key&gt;RANDOMKEY&lt;\/api_key&gt;\n&lt;\/integration&gt;<\/pre>\n\n\n\n<p>In this example we tied OSSEC to the&nbsp;<strong>immediate_response<\/strong>&nbsp;group, so any serious availability issue will be pushed straight to the Pagerduty escalation. Similar to the Slack integration, you can tie it to alert levels (using &lt;level&gt;) or to specific alert ids (using &lt;rule_id&gt;).<\/p>\n\n\n\n<h5>Adding More Integrations<\/h5>\n\n\n\n<p>That\u2019s it for now, however, adding new integrations to OSSEC is very easy and we plan to add more very soon. Hipchat is the next&nbsp;one on our list.<\/p>\n\n\n\n<p>Are\u00a0there any other integrations you want to see? Let us know and we will make it happen.<\/p>\n\n\n\n<h2>Need Help with OSSEC?<\/h2>\n\n\n\n<p>We leverage&nbsp;<a rel=\"noreferrer noopener\" href=\"http:\/\/dcid.me\/ossec\" target=\"_blank\">OSSEC<\/a>&nbsp;extensively across all our products to help monitor and protect our servers. If you are not familiar with OSSEC, it is an open source Intrusion Detection System (HIDS); with a powerful correlation and analysis engine that integrates log analysis, file integrity monitoring, rootkit detection, real-time alerting, and active response.<\/p>\n\n\n\n<p>It provides complete coverage if you are looking for an endpoint (server) security solution. <\/p>\n\n\n\n<ul><li>If you have not used OSSEC before, I recommend reading my guide&nbsp;to get started:&nbsp;<a rel=\"noreferrer noopener\" href=\"http:\/\/dcid.me\/texts\/my-ossec-setup-manual.html\" target=\"_blank\">http:\/\/dcid.me\/texts\/my-ossec-setup-manual.html<\/a><\/li><li>If you need help with your OSSEC implementation, we provide professional consultation at <a href=\"https:\/\/coldpath.net\/ossec-support\/\">ColdPath<\/a><\/li><\/ul>\n\n\n\n<p><em>Note that OSSEC requires root access to your servers and is meant for network \/ server administrators with Linux skills.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the new features that we open sourced and pushed to OSSEC is an \u201cintegrator\u201d daemon that we have been using internally to connect OSSEC to external APIs and alerting tools. The first two APIs we officially added were for Slack and PagerDuty. To get started, you have to download OSSEC from our fork, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/posts\/390"}],"collection":[{"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/comments?post=390"}],"version-history":[{"count":2,"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/posts\/390\/revisions"}],"predecessor-version":[{"id":403,"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/posts\/390\/revisions\/403"}],"wp:attachment":[{"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/media?parent=390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/categories?post=390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/tags?post=390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}