Skip to content

etn-ccis/dynatrace-github-action

 
 

Repository files navigation

Dynatrace GitHub Action

GitHub Super-Linter CI Check dist/ CodeQL Coverage

This GitHub Action enables CI/CD workflows to report Events and Metrics to a Dynatrace monitoring environment using the REST API. For additional context and details please refer to the Dynatrace API.

This repository was bootstrapped using the typescript-action template.


Tags

The following tags are available for the dynatrace-oss/dynatrace-github-action action.

  • main
  • v$MAJOR (eg: v2)
  • v$MAJOR.$MINOR (eg: v2.1)
  • v$MAJOR.$MINOR.$PATCH (eg: v2.1.6)

Note

See to the Releases page for all available versions.

Usage

Inputs

Name Type Description Default
url String Dynatrace URL [1] required
token String Dynatrace API-Token required
metrics YAML Inline YAML list of Metrics to send []
events YAML Inline YAML list of Events to send []
sdlc-events YAML Inline YAML list of SDLC Events to send via OpenPipeline []
  1. url should be the LIVE Dynatrace domain, eg: https://{your-environment-id}.live.dynatrace.com

API Token

Your token must be a Dynatrace API token with the following permissions granted to it:

  • Read Metrics (metrics.read)
  • Read Events (events.read)
  • Ingest Metrics (metrics.ingest)
  • Ingest Events (events.ingest)
  • Ingest SDLC Events (openpipeline.events_sdlc) — required only when using sdlc-events

Metric Formats

Optionally supplied Metric formats support the following:

  • gauge
  • count

Event Types

Event types must be one of the following:

  • AVAILABILITY_EVENT
  • CUSTOM_ALERT
  • CUSTOM_ANNOTATION
  • CUSTOM_CONFIGURATION
  • CUSTOM_DEPLOYMENT
  • CUSTOM_INFO
  • ERROR_EVENT
  • MARKED_FOR_TERMINATION
  • PERFORMANCE_EVENT
  • RESOURCE_CONTENTION_EVENT

SDLC Events

SDLC (Software Development Lifecycle) events are ingested via the Dynatrace OpenPipeline Ingest API at the /platform/ingest/v1/events.sdlc endpoint.

Each SDLC event must include the event.id field. Any additional properties are forwarded as-is to the OpenPipeline.

The token must have the openpipeline.events_sdlc scope.

Examples

Important

Make sure to use the latest version from the Releases tab!

Sending a Metric

The following will send a generic untyped metric named github.my.custom.metric to Dynatrace with a value of 1.0 and several dimensions to filter against. In this example you could get all metrics for single repository using the github.repository dimension.

- name: Send metrics to Dynatrace
  uses: dynatrace-oss/dynatrace-github-action@v9
  with:
    url: ${{ secrets.DT_URL }}
    token: ${{ secrets.DT_TOKEN }}
    metrics: |
      - metric: "github.my.custom.metric"
        value: "1.0"
        dimensions:
          github.repository: "${{ github.repository }}"
          github.ref: "${{ github.ref }}"
          github.event_name: "${{ github.event_name }}"
          github.actor: "${{ github.actor }}"

Sending an Event

The following will send a INFO event named GitHub Event, targeting the entity type(host),entityName(myHost), with a several properties on the event. In this example you could get all events for single repository using the github.repository property.

See the Entity Selector API for help creating selectors. Below are a few examples:

  • type(host),tag(prod) - Selects all Hosts with a Tag prod.
  • type(service),entityName(login) - Selects all Services with the name login
- name: Send events to Dynatrace
  uses: dynatrace-oss/dynatrace-github-action@v9
  with:
    url: ${{ secrets.DT_URL }}
    token: ${{ secrets.DT_TOKEN }}
    events: |
      - title: GitHub Event
        type: CUSTOM_INFO
        entitySelector: type(host),entityName(myHost)
        properties:
          source: GitHub
          description: This is an example
          github.repository: "${{ github.repository }}"
          github.ref: "${{ github.ref }}"
          github.event_name: "${{ github.event_name }}"
          github.actor: "${{ github.actor }}"

Sending an SDLC Event

The following sends a deployment SDLC event to the Dynatrace OpenPipeline. Any additional properties beyond event.id are forwarded to the pipeline as-is.

- name: Send SDLC event to Dynatrace
  uses: dynatrace-oss/dynatrace-github-action@v9
  with:
    url: ${{ secrets.DT_URL }}
    token: ${{ secrets.DT_TOKEN }}
    sdlc-events: |
      - event.id: "${{ github.run_id }}"
        event.type: deployment
        event.category: DEPLOY
        git.repository: "${{ github.repository }}"
        git.commit: "${{ github.sha }}"
        git.ref: "${{ github.ref }}"
        actor: "${{ github.actor }}"

Local Development

Install the dependencies

npm install

Lint, test and build the TypeScript and package it for distribution

npm run all

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/dynatrace-oss/dynatrace-github-action.

License

See LICENSE

About

An action that pushes metrics and events from GitHub workflows to a Dynatrace monitoring environment

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • TypeScript 100.0%