Skip to content

Commit

Permalink
add action for sending custom metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
aluon committed Mar 19, 2024
1 parent da2d85e commit 1a0c9bc
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
30 changes: 30 additions & 0 deletions send-custom-metrics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## Description

Sends custom metrics to a specified metrics endpoint. This action makes a POST request using a bearer token for authorization.

## Inputs

| parameter | description | required | default |
|---|---|---|---
| METRICS_ENDPOINT_URL| The metrics endpoint URL where the data will be sent. | `true` | |
| BEARER_TOKEN | The authorization token for the endpoint. | `true` | |
| data | The metric data to send, formatted as required by the endpoint. | `true` | |

### Example Usage

Replace `METRICS_ENDPOINT_URL` and `BEARER_TOKEN` with your actual metrics endpoint URL and bearer token, which should be stored as secrets in your GitHub repository.

```
jobs:
send-metrics:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Send Custom Metrics
uses: your-username/send-custom-metrics-action@main
with:
METRICS_ENDPOINT_URL: ${{ secrets.METRICS_ENDPOINT_URL }}
BEARER_TOKEN: ${{ secrets.BEARER_TOKEN }}
data: 'your_metric{label="value"} 123'
```
23 changes: 23 additions & 0 deletions send-custom-metrics/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Send Custom Metrics
description: Sends custom metrics to an endpoint

inputs:
METRICS_ENDPOINT_URL:
description: The metrics endpoint URL
required: true
BEARER_TOKEN:
description: The authorization token for the endpoint
required: true
data:
description: The metric data to send
required: true

runs:
using: composite
steps:
- name: Send Metric
shell: bash
run: |
curl -H "Authorization: Bearer ${{ inputs.BEARER_TOKEN }}" \
-X POST "${{ inputs.METRICS_ENDPOINT_URL }}" \
-d '${{ inputs.data }}'

0 comments on commit 1a0c9bc

Please sign in to comment.