UQL help to parse json with Infinity plugin

  • What Grafana version and what operating system are you using?
    Grafana v10.2.1 - hosted on debian as docker

  • What are you trying to achieve?
    Trying to Query a JQL file using the Infinity-plugin and UQL script

  • How are you trying to achieve it?
    A snip of my JSON file

[
{
    "project_name": "TRA BT M7 Audio & Displays",
    "project_key": "TRA_BT_M7",
    "release_name": "M7_FS_SWPx.x.x",
    "release_released": false,
    "release_start_date": null,
    "release_expected_end_date": null,
    "release_end_date": null,
    "release_issue_count_done": 2,
    "release_issue_count_in_progress": 0,
    "release_issue_count_to_do": 2,
    "release_issue_count_total": 4,
    "coupled_test_cycle_lines": [
      {
        "project_key": "",
        "project_name": "",
        "test_cycle_name": "no test cycle found",
        "test_cycle_environment": "",
        "release_name": "",
        "results_passed": 0,
        "results_failed": 0,
        "results_incomplete": 0,
        "results_blocked": 0,
        "results_not_tested": 0,
        "results_na": 0,
        "results_total": 0,
        "defects_resolved": 0,
        "defects_open": 0,
        "defects_total": 0
      }
    ],
    "project_requirement_count_with_passed_test_runs": 0,
    "project_requirement_count_with_failed_test_runs": 0,
    "project_requirement_count_covered_no_test_result": 0,
    "project_requirement_count_covered": 0,
    "project_requirement_count_uncovered": 0,
    "project_requirement_count_total": 0,
    "release_nc_count_open_minor_low": 0,
    "release_nc_count_open_minor_high": 0,
    "release_nc_count_open_major": 0,
    "release_nc_count_total": 2,
    "jenkins_job_name": null,
    "jenkins_job_description": null,
    "jenkins_job_branch_name": null,
    "jenkins_job_branch_health_score": null,
    "jenkins_job_branch_last_build_result": null,
    "jenkins_job_branch_last_build_number": null
  },
  {
    "project_name": "TRA W&B",
    "project_key": "TRA_STA_CL_WB",
    "release_name": "Citylink_FS_SWP3.05-RC_INT",
    "release_released": true,
    "release_start_date": null,
    "release_expected_end_date": "2023-09-12",
    "release_end_date": "2023-09-12",
    "release_issue_count_done": 1,
    "release_issue_count_in_progress": 0,
    "release_issue_count_to_do": 1,
    "release_issue_count_total": 2,
    "coupled_test_cycle_lines": [
      {
        "project_key": "TRA_STA_CL_WB",
        "project_name": "TRA W&B",
        "test_cycle_name": "Testcycle SWP3.5.0",
        "test_cycle_environment": "",
        "release_name": "",
        "results_passed": 73,
        "results_failed": 13,
        "results_incomplete": 0,
        "results_blocked": 13,
        "results_not_tested": 77,
        "results_na": 0,
        "results_total": 176,
        "defects_resolved": 1,
        "defects_open": 12,
        "defects_total": 13
      },
      {
        "project_key": "TRA_STA_CL_WB",
        "project_name": "TRA W&B",
        "test_cycle_name": "SWP3.5.0",
        "test_cycle_environment": "",
        "release_name": "",
        "results_passed": 0,
        "results_failed": 0,
        "results_incomplete": 0,
        "results_blocked": 0,
        "results_not_tested": 0,
        "results_na": 0,
        "results_total": 0,
        "defects_resolved": 0,
        "defects_open": 0,
        "defects_total": 0
      }
    ],
    "project_requirement_count_with_passed_test_runs": 2,
    "project_requirement_count_with_failed_test_runs": 4,
    "project_requirement_count_covered_no_test_result": 0,
    "project_requirement_count_covered": 6,
    "project_requirement_count_uncovered": 0,
    "project_requirement_count_total": 6,
    "release_nc_count_open_minor_low": 1,
    "release_nc_count_open_minor_high": 0,
    "release_nc_count_open_major": 0,
    "release_nc_count_total": 1,
    "jenkins_job_name": "46.00.0032",
    "jenkins_job_description": "SYS Wales and Borders",
    "jenkins_job_branch_name": "release/3.5.0",
    "jenkins_job_branch_health_score": 100,
    "jenkins_job_branch_last_build_result": "SUCCESS",
    "jenkins_job_branch_last_build_number": 13
  }
]

I want to build a UQL query that filters that item, where “release_name”== “Citylink_FS_SWP3.05-RC_INT”, then I want to mv-expand " “coupled_test_cycle_lines”. So it results in a data-table with test_cycle_lines.

I tried:

parse-json
| where "release_name" = "Citylink_FS_SWP3.05-RC_INT"
| mv-expand "coupled_test_cycle_lines"

But not working :frowning:

Trying the UQL below works and results in the table I want, however I need to be able to filter on “release_name” using a dashboard variable. (Above I used a test value ‘Citylink_FS_SWP3.05-RC_INT’)

parse-json
| mv-expand "coupled_test_cycle_lines"

I think there are couple of syntax errors.

  • where condition require == (double equal)
  • where condition string part needs to be single quoted. Double quoted strings refer field names usually.

Try

parse-json
| where "release_name" == 'Citylink_FS_SWP3.05-RC_INT'
| mv-expand "coupled_test_cycle_line"="coupled_test_cycle_lines"

I think I found what I need. This works for me: