Grafana clarifications

I have a query type variable …

Query Type : Infinity
Type : JSON
Parser : Backend
Source : URL

Method : GET

URL : /adaptations/madtns/objects/MADTNS-NRGN-2

In the “Parsing options and Result fields” → Rows/Root , I am using the following expression

$.content[dn=“PLMN-PLMN/NSPQ-1/NRGN-CENTRAL”].id

where “content” is the root of the JSON array .

This works fine and fetches the “id” field correctly for me.

But instead of the hardcoded “dn” value , I need to pass a variable as the “dn” value.

I stored the value in a custom variable “dnvalue” and when I pass that variable name as the “dn” value , it is not able to resolve ..
Something like below

$.content[dn=$dnvalue].id

How do I pass the variable as the “dn” value in such an expression …

Please let me know …

Thanks,
Nilanjan

@nmitra can you please post sample json data returned by the rest api call?

The sample json response array is as follows -

                                "content": [
                                    {
                                        "dn": "PLMN-PLMN/NSPQ-1/NRGN-CENTRAL",
                                        "id": "12279988000000000104",
                                        "name": "PLMN-PLMN/NSPQ-1/NRGN-CENTRAL",
                                        "objectLevel": "MADTNS-NRGN-2",
                                        "type": "managed"
                                    },
                                    {
                                        "dn": "PLMN-PLMN/NSPQ-1/NRGN-LAB",
                                        "id": "12279988000000542045",
                                        "name": "PLMN-PLMN/NSPQ-1/NRGN-LAB",
                                        "objectLevel": "MADTNS-NRGN-2",
                                        "type": "managed"
                                    },
                                    {
                                        "dn": "PLMN-PLMN/NSPQ-1/NRGN-SOUTH",
                                        "id": "12279988000000000182",
                                        "name": "PLMN-PLMN/NSPQ-1/NRGN-SOUTH",
                                        "objectLevel": "MADTNS-NRGN-2",
                                        "type": "managed"
                                    }

]

“content” is the root

My requirement is to fetch the “id” value for a particular “dn” . The “dn” value should be passed as a variable.

How to do it in Grafana ?

Please let me know.

here you go try this

1 Like