-
Notifications
You must be signed in to change notification settings - Fork 17
60 lines (51 loc) · 2.19 KB
/
new_relic.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: new-relic
on:
workflow_run:
workflows: ['Merge to main','Pull Request Workflow']
types: [completed]
env:
GHA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }}
NEW_RELIC_ACCOUNT_ID: ${{ secrets.NEW_RELIC_ACCOUNT_ID }}
OTEL_EXPORTER_OTEL_ENDPOINT: ${{ secrets.NEW_RELIC_OTEL_STAGING_ENDPOINT }}
GHA_RUN_ID: ${{ github.event.workflow_run.id }}
GHA_RUN_NAME: ${{ github.event.workflow_run.name }}
jobs:
new-relic-exporter:
name: new-relic-exporter
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: new-relic-exporter
uses: newrelic-experimental/gha-new-relic-exporter@latest
custom:
name: Report custom event
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Setup jq
run: sudo apt-get install -y jq
- name: Send workflow run details to new relic
run: |
event_type="FluentBitPackageWorkflowRun"
entity_name="${{ github.repository }}"
id="${{ github.event.workflow_run.id }}"
workflow_name="${{ github.event.workflow_run.name }}"
conclusion="${{ github.event.workflow_run.conclusion }}"
run_number="${{ github.event.workflow_run.run_number }}"
html_url="${{ github.event.workflow_run.html_url }}"
echo $(jq -n \
--arg event_type "$event_type" \
--arg entity_name "$entity_name" \
--arg id "$id" \
--arg workflow_name "$workflow_name" \
--arg conclusion "$conclusion" \
--arg run_number "$run_number" \
--arg html_url "$html_url" \
'{eventType: $event_type, "entity.name": $entity_name, id: $id, workflow_name: $workflow_name, conclusion: $conclusion, run_number: $run_number, html_url: $html_url }') \
> workflow_run.json
gzip -c workflow_run.json | curl -X POST -H "Content-Type: application/json" \
-H "Api-Key: ${{ env.NEW_RELIC_LICENSE_KEY }}" -H "Content-Encoding: gzip" \
https://staging-insights-collector.newrelic.com/v1/accounts/${{ env.NEW_RELIC_ACCOUNT_ID }}/events --data-binary @-