Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Allure report data to show on Grafana dashboard

I am trying to display the Allure report data on Grafana dashboard for my pytest (python + selenium) automation project. I am generating a allure report by given a run by jenkins. Need some heads up on how to show my jenkins run report to grafana. Is there any API/Plugin to send allure results to any time-series database (Influxdb or Prometheus)?

like image 287
Anurag Gupta Avatar asked Jan 25 '26 16:01

Anurag Gupta


1 Answers

Allure generates influxdb and prometheus files in export directory. I am about to write pytest 'plugin' that feeds this file to influxDB database. After that you set Grafana to pull from that database and show data.

Edit: I dont use selenium or jenkins, so for console pytest run I simply added this code (pytest hook) to conftest.py file:

from influxdb_client import InfluxDBClient
from influxdb_client.client.write_api import SYNCHRONOUS


def pytest_terminal_summary(terminalreporter, exitstatus, config):
    influx_db_file = open('allure-html/export/influxDbData.txt', 'r')
    lines = influx_db_file.readlines()
    token = "MyToken"
    org = "MyOrg"
    bucket = "MyBucket"
    client = InfluxDBClient(url="http://localhost:8086", token=token)
    write_api = client.write_api(write_options=SYNCHRONOUS)

    for line in lines:
        write_api.write(bucket, org, line.strip())

This hook is executed when the pytest is finished. You have to pay attention to your influx url, and also your token, org and bucket values.

like image 143
pera Avatar answered Jan 27 '26 06:01

pera



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!