markdown 整合:松弛到OpsGenie

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 整合:松弛到OpsGenie相关的知识,希望对你有一定的参考价值。

## 1. Create Automation Senario
This step will create the automation pipeline in order of operation.

### 1.1. Webhook Trigger (In Integromat)
In integromat, create a new senario and add a webhook trigger:
1. After creating a senario, click on the `?` bubble to define the triggering action.
2. Add  a 'Custom webhook' trigger as the first step in the automation pipeline.  This will be an `INSTANT` trigger that will execute whenever integromat receives data.
3. Configure a new inbound webhook called `Slack - Outgoing Webhook` so you will know what will be sending data inbound.
4. Set 'Max number of results' to `3`
5. Copy the actual hook address (EX: https://hook.integromat.com/____hash____) as you will need it in the next step.
6. Click 'Ok'

### 1.2. Create Outgoing Webhook (In Slack)
1. Assuming you are logged in on slack in your browser, you should be able to access the outgoing webhooks endpoints: https://meltwater.slack.com/apps/A0F7VRG6Q-outgoing-webhooks
   * If watching "#fou-drone-service" you can just add your triggers webhook to the `URL(s)` list (one per line) found in the [#fou-drone-service outgoing webhook](https://meltwater.slack.com/services/BHL172QAH) and add your local user-id in a `Hey <@__user_id__>` CSV match list
   * If watching "#fou-grafana-service" you can just add your triggers webhook to the `URL(s)` list (one per line) found in the [#fou-grafana-service outgoing webhook](https://meltwater.slack.com/services/BHL172QAH) and add your local user-id in a `Hey <@__user_id__>` CSV match list
   * If watching "#foundation-mission" you can just add your triggers webhook to the `URL(s)` list (one per line) found in the [#foundation-mission outgoing webhook](https://meltwater.slack.com/services/BHL172QAH) and add your local user-id in a `Hey <@__user_id__>` CSV match list
   * If you are watching something new or just want work-load separation, feel free to create your own
2. Assuming you have elected to create your own and have already clicked on the add button, the following base configs may help.
   1. `Channel` should be set to a single chatroom you want to monitor
   2. `Trigger Word(S)` match from the beginning of the line, so we really have no choice but to watch tails threaded ping since that will always hold the format of `^Hey <@__oncall_user__> ! <@__requestor__> said: __original_message_`  (__EX__: `Hey <@UA7T176Y5>`)
   3. `URL(s)` should contain the webhook URL you created in step 1.1.
   4. `Token` used for verification / anti-spam if you need it, I don't use this feature yet
   5. `Descriptive Label` Should be something similar to `Team: channel-name` (__EX__: `A-Team: fou-drone-service`)
   6. `Customize Name` Should reflect the service `Integromat: Team` (__EX__: `Integromat: A-Team`)
   7. `Translate User IDs` Make sure you take the global ID's and shift them to the local workspace ones (easier to parse)
3. Click 'Save settings'

### 1.3. Test Webhook (Slack / Integromat)
1. In Integromat, set the 'Run once' trigger so that you can parse out sample data (saves having to build a data structure)
2. In the slack room you added, trigger the message by sending a `Hey @__your_id_here__`
3. In Integromat you should observe an execution which will have populated the webhook with data it will use from that point forward.

### 1.4. Add a Text Parsing Tool (In Integromat)
1. Using the 'Tools' menu, add a 'Match pattern' text parsing module
3. Attach it to the previous entry in the workflow
2. Set the `Pattern` to `.*!\s+<@(.*)>\s+said.*`
3. Ensure `Case sensitive` option is only one selected.
4. Set the `Text` box to the `text` field from the webhook
5. Click 'Ok'
6. Right-click on the module and 'Rename' it to 'Find (Real Requestor)'

### 1.5. Add a HTTP Request Operation (In Integromat)
1. Ok, I lied, you will need to get your token for the slack API
   * Visit https://api.slack.com/methods/users.info/test
   * Add your global User ID to the `user` field
   * Click 'Test Method'
   * Copy the URL with key that is returned.
2. Add a new 'HTTP' module with a 'Make a request' option
3. Attach it to the previous entry in the workflow
4. `URL` should be set to the value you copied with the 'user' parameter edited to be the drop-in `$1` from the previous match
5. Click 'Ok'
6. Right-Click on the module and 'Rename' to `Slack (Real Requestor)`

### 1.6. Add a JSON Parser Operation (In Integromat)
1. Add a new 'JSON' module with a 'Parse JSON' option
2. Attach it to the previous entry in the workflow
3. Leave the `Data structure` field empty so that it is dynamic
4. Ensure the `JSON string` segment is populated with the `Data` from the HTTP call in the prior step.
5. Click 'Ok'
6. Right-Click on the module and 'Rename' it to `JSON (Requestor)`

### 1.7. Test Webhook (Slack / Integromat)
1. In Integromat, set the 'Run once' trigger so that you can parse out sample data (saves having to build a data structure)
2. In the slack room you added, trigger the message by sending a `Hey @__your_id_here__`
3. In Integromat you should observe an execution which will have populated the webhook with data it will use from that point forward.

### 1.8. Add a HTTP Request Operation (In Integromat)
1. Add a new 'HTTP' module with a 'Make a request' option
2. Attach it to the `Remove CRs` module in the workflow
3. Check the `Show advanced settings` checkbox
4. Ensure the `Evaluate all states as errors` checkbox is checked
5. `URL` should be set to `https://api.opsgenie.com/v2/alerts`
6. `Method` should be set to `POST`
7. `Body type` should be set to `Raw`
8. `Content type` should be set to `JSON (application/json)`
9. `Headers` should be set to a team-owned API integration in OpsGenie
   * Navigate to team dashboard in OpsGenie
   * Choose 'Integrations' from the navigation bar
   * Choose 'Add Integration' (unless you are reusing or already have one)
   * Copy the API Key from the 'Settings' of the integration you have added / edited
   * Click the 'Add a header' `+`
   * Set `Name` to `Authorization`
   * Set the `Value` to `GenieKey __copied_api_key_from_opsgenie__`
10. Check the `Reject connections that are using unverified certs`
11. Check the `Disable serialization of multiple same query string keys as arrays`
12. Check the `Requet compressed content`
13. `Request content` should be set to:

```json
{
 "message": "Slack Alert ({{6.channel_name}})",
 "alias": "slack/ateam/{{6.channel_name}}",
 "description":"Help {{27.user.real_name}} in #foundation-mission thread https://{{6.team_domain}}.slack.com/archives/{{6.channel_id}}/p{{6.timestamp}}",
 "responders":[{
   "username":"brian.burnett@meltwater.com",
   "type":"user"
 }],
 "visibleTo":[{
   "name":"ateam",
   "type":"team"
 }],
 "tags": [
   "slack",
   "mention",
   "{{6.channel_name}}"
 ],
 "entity":"{{ifempty(27.user.profile.email; 27.user.real_name)}}"
}
```
Once you are done adding the HTML above, there are a couple steps to remember.
1. Click 'Ok' to save or it won't
2. Right click on the module and rename it to 'OpsGenie (Alert)'
3. Click on the connector between the router and the OpsGenie (Alert) modules and filter down to the userID's that actually want to be paged.

## 2. Filtering Inbound Traffic
To ensure that nobody else is sending you messages you don't want...
1. Click on the connector between the webhook and the initial text parser for the 'Find (Real Requestor)'
2. Filter on the following:
   * `user_id` of the webhook equals `UB6SQ901L` (the tails uid)
   * __AND__
   * `trigger_word` of the webhook contains your own personal uid

以上是关于markdown 整合:松弛到OpsGenie的主要内容,如果未能解决你的问题,请参考以下文章

markdown 松弛的黑暗主题

sh OpsGenie:将模板化集成复制到团队

在可在 OpsGenie 中访问的 Splunk OpsGenie 应用程序中设置优先级

OpsGenie 不会在 AWS 仪表板或 terraform 中自动确认 SNS 订阅

Opsgenie powershell 警报帖子不起作用

SpringBoot整合Markdown实现图片上传和图片再次回显(详细步骤)