From 1a0c9bc89de547625401c203fbefd54c9628f8bc Mon Sep 17 00:00:00 2001 From: Alan Luong Date: Tue, 19 Mar 2024 17:41:42 -0400 Subject: [PATCH] add action for sending custom metrics --- send-custom-metrics/README.md | 30 ++++++++++++++++++++++++++++++ send-custom-metrics/action.yaml | 23 +++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 send-custom-metrics/README.md create mode 100644 send-custom-metrics/action.yaml diff --git a/send-custom-metrics/README.md b/send-custom-metrics/README.md new file mode 100644 index 0000000..aa7fc6f --- /dev/null +++ b/send-custom-metrics/README.md @@ -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' +``` diff --git a/send-custom-metrics/action.yaml b/send-custom-metrics/action.yaml new file mode 100644 index 0000000..2e12832 --- /dev/null +++ b/send-custom-metrics/action.yaml @@ -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 }}'