Grafana Selenium Dashboard with Flux QL does not yield desired result

I am exploring Grafana with influxdb for Selenium Test Reports and was successful into sending metrics to Influx > Grafana but my dashboard yield separate reports against each build execution. One has to manually select report from the dropdown to visualize build specific report.

LIKE:

Is there’s any way to generate reports grouped together as Build 1, Build 2 and so on with PASS/FAIL/SKIP count in a tabular way. Click on each Build report will open new dashboard highlighting all the test cases within that report.

Sample Report:

I have tried below set of queries but nothing yielded positive result.

from(bucket: "sel")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "test_execution")
  |> filter(fn: (r) => r["MARKER"] == "Edge_Management")
  |> filter(fn: (r) => r["_field"] == "NAME")
  |> filter(fn: (r) => r["BUILD_NUMBER"] == "1")
  |> filter(fn: (r) => r["STATUS"] == "FAIL" or r["STATUS"] == "PASS")
  |> group(columns: ["MARKER"])

  |> yield()




from(bucket: "sel")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "test_execution")
  |> filter(fn: (r) => r["MARKER"] == "Edge_Management")
  |> filter(fn: (r) => r["_field"] == "DURATION")
  |> filter(fn: (r) => r["BUILD_NUMBER"] == "1")
  |> filter(fn: (r) => r["STATUS"] == "FAIL" or r["STATUS"] == "PASS")
  |> group(columns: ["MARKER"])

  |> count(column: "STATUS")
  |> yield()


 from(bucket: "sel")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "test_execution")
  |> filter(fn: (r) => r["MARKER"] == "Edge_Management")
  |> filter(fn: (r) => r["_field"] == "NAME")
  |> filter(fn: (r) => r["BUILD_NUMBER"] == "1")
  |> filter(fn: (r) => r["STATUS"] == "FAIL" or r["STATUS"] == "PASS" )
  |> count()
  |> group(columns: ["MARKER"])
  |> yield(name: "MARKER")



  from(bucket: "sel")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "test_execution")
  |> filter(fn: (r) => r["_field"] == "NAME")
  |> filter(fn: (r) => r["STATUS"] == "FAIL" or r["STATUS"] == "PASS")
  |> count()
  |> group(columns: ["MARKER","BUILD_NUMBER"])
  |> yield()

Below are my selenium code:

private void sendTestMethodStatus(ITestResult iTestResult, String status) {
Point point = Point.measurement("test_execution")
        .addTag("BUILD_NUMBER", "3")
        .addField("NAME", iTestResult.getName())
        .addTag("STATUS", status)
        .addTag("MARKER", "Edge_Management")
        .addField("DURATION", (iTestResult.getEndMillis() - iTestResult.getStartMillis()))
        .time(System.currentTimeMillis(), WritePrecision.MS);

InfluxListener.send(point);

public static void send(final Point point) {

InfluxDBClient influxDBClient = InfluxDBClientFactory.create("http://localhost:8086", token, org, bucket);
WriteApiBlocking writeApi = influxDBClient.getWriteApiBlocking();
writeApi.writePoint(point);

}

Grafana Version: 9.0.0 InfluxDB Version: 2.3.0

It’s group by issue, you can try :
add “|>group()” in your flux query column[“name1”,“name2”]
or play with transformation in grafana like, “prepare time series”, “label to field”

I have tried with group as shown in above examples. But none of them shows correct data. Would you mind helping me with accurate query here? It would be helpful.

Please provide sample data as csv inline as follows

table,_start,_stop,_time,_value,_field,_measurement,uic
0,2022-07-08T23:26:22.938437362Z,2022-07-08T23:27:22.938437362Z,2022-07-08T23:26:24Z,494,gpsaltitude,test,111

hard to provide flux guidance without sample data.

Will this help?

test_execution,BUILD_NUMBER=3,MARKER=Edge_Management,STATUS=FAIL DURATION=50510i,NAME=“onboardAppThroughExternalRepo” 1657553018809

Or this?

_start 3 _stop 3 _value 3 MARKER 3 STATUS 3 _field 3 _measurement 3
40:28.9 55:28.9 1 Edge_Management FAIL NAME test_execution
40:28.9 55:28.9 1 Edge_Management SKIPPED NAME test_execution
1 Like

Any suggestions here?