• Contact us
    Search

    How to transfer Robot Framework results from Jenkins to Grafana

    Samuel Enderwitz

    Written by:
    Samuel Enderwitz

    In this blog you’ll learn how to move your test results from Robot Framework (an open source, keyword-driven test automation framework) to your Jenkins Pipeline so that they’re visible in Grafana. Grafana is an open source analytics and monitoring solution.

    You may have a number of pipelines in your Jenkins (an open source automation server which comes in useful for continuous integration). A few of them may have automated Robot Framework tests.

    By linking these tests to Grafana via Jenkins, you gain visibility over your test cases. Instead of needing to check all of them frequently, you can create a monitoring view to track your tests.

    Then you can see what happens in your tests and if you see that there is a problem, you can dig deeper and fix it.

    What you will need

    Steps

    #1 Configure Jenkins so that you can publish the data

    1. You need to install the plugins ‘Robot Framework plugin’ and ‘InfluxDB Plugin’ to Jenkins.

      Both plugins were created by and are currently maintained by Eficode and are one of the many ways we contribute to the open source community.

    2. Go to ‘Manage Jenkins > Configure System > InfluxDB Targets’ and enter the credentials of InfluxDB.

      Now all results of Jenkins and Robot Framework are published to InfluxDB.

    #2 Configure the pipeline to publish to InfluxDB

    Add a new step to your pipeline after the results of Robot Framework get published

    robot outputPath: 'out/’

    Remember to adjust the path to the folder your Robot Framework log and report files are located in.

    Below is a small full pipeline example with running Robot Framework:

    pipeline {
            stages {
                   stage(’Test’) {
                           steps {
                                   sh ‘robot -d out/ my_test/’
                             }
                     }
             post {
                     always {
                            robot outputPath: ‘out/’
                            influxDbPublisher selectedTarget: ‘myDb’
                      }
               }
       }

    #3 Connect Grafana to InfluxDB and create a dashboard

    1. Install the ‘InfluxDB’ data source.
    2. Go to ‘Configuration > Data Sources > Influxdb’ and enter the credentials of InfluxDB.
    3. Select your wanted dashboard or create a new one.
    4. Press ‘Add panel’ and choose ‘Add Query’.
    5. As a query you select ‘Influxdb’.
    6. Enter your datanull
      1. ‘FROM’: The type of measurement. Here you can find all types.
      2. ‘SELECT’: Select the field you want.
      3. ‘GROUP BY’: Group by the`project_path`, so that you get one graph per job. If you want to merge all branch jobs in a multibranch pipeline to one graph, use ‘project_name’.
      4. ‘ALIAS BY’: Rename the displayed name.
    7. Now switch to ‘Visualization’ on the left and choose ‘Gauge’.
    8. You have quite a lot of options to optimize your graph. Just take a look through the options.

    Further reading

    I hope you found my tutorial helpful. Here’s some further reading to help you along.

    Automation is a bread and butter practice of DevOps, which helps the software development process become less painful and creative. So remember to have fun with it!

    DEVOPS 2020 will bring together the DevOps community.  Get tickets