GithubHelp home page GithubHelp logo

mdb / paas-grafana-annotation-resource Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alphagov/paas-grafana-annotation-resource

0.0 2.0 0.0 35 KB

A concourse resource for creating and updating Grafana annotations

License: MIT License

Dockerfile 0.77% Makefile 2.24% Go 96.99%

paas-grafana-annotation-resource's Introduction

paas-grafana-annotation-resource

CI Workflow GitHub Actions Badge License GitHub Badge

A resource for adding annotations to Grafana dashboards.

The resource represents a single Grafana (version >= 6.4) and this resource can be used to add and update annotations using tags. Version 6.4 and above is required because the resource assumes that resources are represented by a single annotation.

Usage

See the example below for all the pipeline code.

If you create an annotation using with put: resource-name, it will be a point-in-time annotation. This put step will write the ID of the current resource to resource-name/id.

In order to make it the annotation a region annotation, put to the resource again, but pass the resource name to the path path param. This will update the annotation, and make it a region beginning when the resource was created, and ending at the current time.

  # Create a point-in-time annotation, e.g. a single event
- put: my-grafana-annotation

- task: do-a-thing-that-takes-some-time

  # Update the point-in-time annotation to be a region
  # The region's duration will be the time taken by the task
- put: my-grafana-annotation
  params:
    path: my-grafana-annotation

Example

In the following example, imagine we are running smoke tests from Concourse, and we want to annotate our Grafana dashboard with a region during which the smoke tests ran.

First define grafana-annotation as a resource type:

resource_types:
  - name: grafana-annotation
    type: docker-image
    source:
      repository: gdsre/grafana-annotation-resource
      tag: latest

Then declare a grafana-annotation resource with a descriptive name:

resources:
  - name: run-smoke-tests-annotation
    type: grafana-annotation
    source:
      url: http://grafana:3000
      username: admin
      password: admin

      tags:
        - run-from-concourse
        - smoke-tests

Then use the resource:

jobs:
  - name: run-smoke-tests
    plan:
      - put: run-smoke-tests-annotation
        params:
          tags:
            - started

      - task: run-smoke-tests
        config:
          platform: linux
          image_resource:
            type: docker-image
            source:
              repository: my-smoke-tests
              tag: latest
          run:
            path: /bin/smoke

      - put: run-smoke-tests-annotation
        params:
          tags:
            - finished

          # The path is the resource name, so the ID is identical to above.
          # This tells the resource that we are updating an existing annotation

          path: run-smoke-tests-annotation

Configuration

The source can be configured like so:

resources:
  - name: my-resource-name
    type: grafana-annotation
    source:

      # Required
      url: http://grafana:3000

      # Required
      username: admin

      # Required
      password: admin

      # Optional
      tags:
        - tag1
        - tag2
        - ((environment))

      # Optional
      env:
        MY_SRC_VAR: ((can_take_variables))

The params can be configured like so:

- put: my-resource-name
  params:

    # Optional
    # These get merged with the env block from source
    env:
      MY_PARAM_VAR: foo-bar

    # Optional
    # Can use environment variables
    template:  "${BUILD_ID} ; ${MY_SRC_VAR} ; ${MY_PARAM_VAR}"

    # Optional
    # Are merged with tags from source
    tags:
      - started

    # Optional
    # See example above
    # - Should not be present if creating a resource
    # - Should be the resource name if updating an annotation
    path: my-resource-name

Notes

  • The tags in source and params are merged

  • When an existing annotation is updated, the tags from creation are overwritten with the tags from the update

  • You should ensure put steps to Grafana in try and ensure + try task steps so that failure to create/update regions in Grafana does not impact your pipeline.

  • Currently updating individual dashboards and panels is not supported. Use tags to view your resources instead.

paas-grafana-annotation-resource's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.