markdown 整合:松弛到OpsGenie和Jira

Posted

tags:

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

## 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 Routing Tool (In Integromat)
1. Click the 'Cog' in the 'Tools' menu and choose 'Router'
2. Attach it to the previous entry in the workflow

### 1.9. 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.

### 1.10. Add a HTTP Request Operation (In Integromat)
1. Add a new 'HTTP' module with a 'Make a Basic Auth request' option
2. Attach it to the `Router` module in the workflow
3. Add your Jira account info to `Credentials` and name it 'Jira (Meltwater)'
4. Make the `URL` show the following `https://jira.meltwater.com/rest/agile/1.0/board/___team_board_id___/sprint?state=active`
5. Make the `Method` a `GET`
6. Click 'Ok'
7. Right click on the module and rename it to 'Jira (Get Sprint)'
8. Click on the connector between this and the previous module and filter it if your project runs multiple concurrent sprints.

### 1.11. 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 (SprintID)`

### 1.12. 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.13. Add an Iterator (Integromat)
1. Add a new 'Iterator' tool  from the tools menu
2. Select the 'Sprint ID' 'Values[]' array
3. Connect it to the 'SprintID'  JSON Parser from step 1.12.

### 1.14. Add a JIRA Software Operation (Integromat)
1. Add a new 'Create Issue' Jira integration
2. Add your credentials for Jira
3. Connect it to the 'Iterator' from the previous step
4. Create a filter based on the 'name' starting with `A`/`B`/`M`
5. Once the symantecs are done, follow the steps below to configure the integration:
   1. `Connection` Add your credentials for JIRA here
   2. `Project` should be set to your teams by selection
   3. `Issue Type` should be set to whatever your team would like to use to capture these messages
   4. `Summary` should be set to something that shows where it came from, perhaps consider `[channel_name] Help json_requestor_real_name in slack`
   5. Ensure `Issue Type` is set to 'Task'
   6. `Sprint` Should be set to the sprint you have filtered out will only have one option pesent, the active sprint. You will want to set this to the `id` of the sprint iterator that matched the filter.
   7. `Project` value should be set to your teams project
   8. `Reporter` can be set to a robot account or your userID if you like.  Optionally you can take the email from the real-requestor and add an option to parse out the `@meltwater.com` from the email address.
   9. `Priority` should be set to an agreed upon value
   10. `Story Points` can be set to a value sufficient for on-call support or left empty
   11. `Labels` can be super helpful for searching, we use the following:
       * `slack` (shows it came from slack)
       * `unplanned` (separates planned from unplanned sprint work)
       * `channel_name` (So you can search he channel name)
   12. `Team` should be set to your team (if you use this field)
   13. `Description` you can set to whatever in reality, we found the following useful:

```
h4.{{27.user.real_name}} ({{now}})
{quote}{{6.text}}{quote}
- *User Timezone*: {{27.user.tz_label}}
- *User Phone*: {{27.user.profile.phone}}
- *Thread*: https://{{6.team_domain}}.slack.com/archives/{{6.channel_id}}/p{{6.timestamp}}

h4.Acceptance Criteria
- Determine path forward
- Ensure documentation if required
```

## 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和Jira的主要内容,如果未能解决你的问题,请参考以下文章

markdown 松弛的黑暗主题

最短路计数(松弛操作处理)

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

最小环

最小环

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