How to create Data Links in NodeGraph panel?

Hi, I’m using NodeGraph panel with Nodegraph-API Datasource. Lately I’ve seen in documentation: Node graph | Grafana documentation that there is possibility to nest data links into node data (demo gif). I can see this also when I connect to Grafana TestData datasource, but I don’t understand how it’s done.

I found another post on this topic here:

/t/missing-documentation-on-how-to-achieve-data-links-in-the-nodes-and-expanding-hidden-nodes-for-nodegraph-plugin/88306

and issue on Github Add Node Graph Data Link · Issue #82739 · grafana/grafana · GitHub but both without any response. Help, please.

Test data link in Nodegraph from TestData datasource:
image

Nodegraph data as table from TestData datasource:

there is a demo of this functionality in the sandbox:

Grafana.

1 Like

The functionality is in the demo but on my awsmanaged instance (running 10.4) there are no data link or field override options.

what does your data look like? can you provide sample data (obfuscated and scrubbed of sensitive data)

here are the requirements

ive got the same issue. i understand that the /api/graph/fields used by the nodegraph datasource plugin should contain field configurations, but there appears to be no documentation for what should be in here.

i’m using something like this, but its not showing the link on nodes with that field_name.

what should this look like?

  "nodes_fields": [
    {
      "field_name": "detail__app_name",
      "type": "string",
      "config": {
        "displayName": "App Name",
        "links": [
          {
            "title": "App dashboard for ${__data.fields.title}",
            "url": "/d/${python_app_dash_id}?from=${__from}&to=${__to}&var-customer=${customer}&var-environment=${environment}&var-topic=${__data.fields.title}"
          }
        ]
      }
    },

the source code from the plugin shows that its not transforming config.links specifically so must be passing them straight through.

       FieldsResponse.forEach((field: any) => {
          // fieldType can be either number of string
          var fieldType = field['type'] === 'number' ? FieldType.number : FieldType.string;
          // add 'name' and 'type' items to the output object
          var outputField: FrameFieldType = { name: field['field_name'], type: fieldType, config: {} };
          // add color for 'arc__*' items(only apperas for the nodes)
          if ('color' in field) {
            outputField.config.color = { fixedColor: field['color'], mode: FieldColorModeId.Fixed };
          }
          // add disPlayName for 'detail__*' items
          if ('displayName' in field) {
            outputField.config.displayName = field['displayName'];
          }
          outputFields.push(outputField);
        });

thanks yosiaz, (your comment appears to have been removed?) yes its not valid JSON, but does that matter?

what would be useful is the documentation for /api/graph/fields that describes the data frame expected

yes it does matter if we want to test things out on our side of things. it helps us help you. otherwise it is will be endless back and forth, stumbling in the dark.

so cleaning up your data for test purposes locally I get

then in data link

OK so lets take the example from the README

pick a node, any node you would like. What needs to be returned in the data frame so that the nodegraph visualisation displays a link against that node?

this is the endpoint /api/graph/data

{
    "edges": [
        {
            "id": "1",
            "mainStat": "53/s",
            "source": "1",
            "target": "2"
        }
    ],
    "nodes": [
        {
            "arc__failed": 0.7,
            "arc__passed": 0.3,
            "detail__zone": "load",
            "id": "1",
            "subTitle": "instance:#2",
            "title": "Service1"
        },
        {
            "arc__failed": 0.5,
            "arc__passed": 0.5,
            "detail__zone": "transform",
            "id": "2",
            "subTitle": "instance:#3",
            "title": "Service2"
        }
    ]
}

here is the output from /api/graph/fields

{
  "edges_fields": [
    {
      "field_name": "id",
      "type": "string"
    },
    {
      "field_name": "source",
      "type": "string"
    },
    {
      "field_name": "target",
      "type": "string"
    },
    {
      "field_name": "mainStat",
      "type": "number"
    }
  ],
  "nodes_fields": [
    {
      "field_name": "id",
      "type": "string"
    },
    {
      "field_name": "title",
      "type": "string"
    },
    {
      "field_name": "mainStat",
      "type": "string"
    },
    {
      "field_name": "secondaryStat",
      "type": "number"
    },
    {
      "color": "red",
      "field_name": "arc__failed",
      "type": "number"
    },
    {
      "color": "green",
      "field_name": "arc__passed",
      "type": "number"
    },
    {
      "displayName": "Role",
      "field_name": "detail__role",
      "type": "string"
    }
  ]
}
1 Like

The below solved it for me

added a url data piece in nodes just for fun: google.com

Then it shows up in this odd , Open in Explore ui piece

thanks for that @yosiasz. thats good to know thats one way to do it.

i was also wondering about using config.links in the fields data frame.
eg if we simplify the fields response to

{
    "edges_fields": [
    ],
    "nodes_fields": [{
            "field_name": "title",
            "type": "string",
            "config": {
                "displayName": "The title",
                "links": [{
                        "title": "link for for ${__data.fields.title}",
                        "url": "https://www.google.com/?${__data.fields.title}"
                    }
                ]
            }
        },
    ]
}

this then adds a link in the node popup.

things to be aware of with the above: the data link wont display if:

  • there is a conflicting field override in the visualisation for the field
  • any variables used, ie ${…} dont exist in the dashboard

there are no helpful error messages in the browser console when nodegraph cant display something.

As mentioned earlier I’ve not been able to find any specification for the dataframe expected from for /api/graph/fields which details the config part (nor has chatgpt). ive raised this as
Documentation feedback: clarify where field configs are set in node graph viz · Issue #99103 · grafana/grafana

1 Like

so couple of ways to address that I would recommend.

  • contribute to the code to implement those features
  • use something different as plugin such as business chart or business text with

plotly

or d3 network

  • submit a bug or feature request