{"id":20585417,"url":"https://github.com/opsdis/nodegraph-provider","last_synced_at":"2025-04-14T21:09:58.823Z","repository":{"id":42024346,"uuid":"453652323","full_name":"opsdis/nodegraph-provider","owner":"opsdis","description":"The nodegraph-provider works with the Grafana datasource \"Node Graph API Datasource Plugin\"","archived":false,"fork":false,"pushed_at":"2024-01-27T11:30:07.000Z","size":513,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-14T21:09:45.803Z","etag":null,"topics":["grafana","node-graph"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opsdis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-30T10:44:53.000Z","updated_at":"2024-03-21T03:45:12.000Z","dependencies_parsed_at":"2022-08-12T02:40:35.542Z","dependency_job_id":null,"html_url":"https://github.com/opsdis/nodegraph-provider","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opsdis%2Fnodegraph-provider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opsdis%2Fnodegraph-provider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opsdis%2Fnodegraph-provider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opsdis%2Fnodegraph-provider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opsdis","download_url":"https://codeload.github.com/opsdis/nodegraph-provider/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248961237,"owners_count":21189993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["grafana","node-graph"],"created_at":"2024-11-16T07:08:03.991Z","updated_at":"2025-04-14T21:09:58.792Z","avatar_url":"https://github.com/opsdis.png","language":"Go","readme":"![Docker Pulls](https://img.shields.io/docker/pulls/athenodon/nodegraph-provider)\n\nnodegraph-provider\n----------------\n\n# Overview\nThe nodegraph-provider works with the Grafana datasource \"Node Graph API Datasource Plugin\", \nhttps://github.com/exaco/nodegraph-api-plugin.\n\nThe nodegraph-provider use a RedisGraph, https://github.com/RedisGraph/RedisGraph, to keep a graph model \nof what to expose to the Node Graph API datasource. \n\nTo create a model the nodegraph-provider expose api endpoints to create and update nodes and edges. \nThe attributes that can be used is limited to the attributes of the Grafana Node Graph panel plugin, \nhttps://grafana.com/docs/grafana/latest/visualizations/node-graph/.\n\n![Overview](docs/nodegraph-provider.png?raw=true \"Overview\")\n\n# Configuration\nFor available configuration check out the `config.yaml`. All configuration can be overridden by environment variables \nexcept the `graph_schemas`.\n\nPrefix all configuration varaibles with `NODEGRAPH_PROVIDER_` and replace `.` with `_`, e.g. set the redis server:\n\n    export NODEGRAPH_PROVIDER_REDIS_HOST=my_redis_host\n    \n\n# Graph schema model\n\nThe graph model must be compatible to the data model for nodes and edges in the Node Graph panel. \nThe attributes allowed is specified at https://grafana.com/docs/grafana/latest/visualizations/node-graph/#data-api.\n\nIn the nodegraph-provider each instance schema of a model is described in the configuration file, e.g.\n\n```yaml\ngraph_schemas:\n  micro:\n    node_fields:\n      - field_name: \"id\"\n        type: \"string\"\n      - field_name: \"title\"\n        type: \"string\"\n      - field_name: \"subTitle\"\n        type: \"string\"\n      - field_name: \"mainStat\"\n        type: \"string\"\n        displayName: \"CPU\"\n      - field_name: \"secondaryStat\"\n        type: \"number\"\n      - field_name: \"arc__failed\"\n        type: \"number\"\n        color: \"red\"\n      - field_name: \"arc__passed\"\n        type: \"number\"\n        color: \"green\"\n      - field_name: \"detail__role\"\n        type: \"string\"\n        displayName: \"Role\"\n    edge_fields:\n      - field_name: \"id\"\n        type: \"string\"\n      - field_name: \"source\"\n        type: \"string\"\n      - field_name: \"target\"\n        type: \"string\"\n      - field_name: \"mainStat\"\n        type: \"number\"\n      - field_name: \"secondaryStat\"\n        type: \"number\"\n      - field_name: \"detail__traffic\"\n        type: \"string\"\n```\n\nThe `graph_schemas` can have multiple named schema definitions. Above is a schema called `micro`.\nThe name is used as a key in all API accesses to support multiple instances. E.g. when setting up the URL in the\nNode Graph API Datasource Plugin we define it as part of the path, `http://localhost:9393/micro`.\nThis enables nodegraph-provider to support multiple data sources in a single instance.\nThe schema defines the different fields and the type, string or number, that are allowed for the specific schema. \n  \n\n# API endpoints\n\nAll endpoint expects the header \"Content-Type\" set to \"application/json\"\n\n## Data source API\n   \n    GET /{graph_schema}/api/graph/data?query=\u003cWHERE clause\u003e\nThe above query parameter is optional, If empty or not set all nodes and edges are returned.\nIf set, it must be a valid Cypher statement, https://neo4j.com/docs/cypher-manual/current/clauses/where/,\nbut with some limitation documented in https://neo4j.com/docs/cypher-manual/current/clauses/where/.\nFor example the Redis Cypher do not support regular expression.\n\n\u003e The `WHERE` should not be part of the query string, and the string must be urlencoded.\n\nThe WHERE clause can only operate where source nodes, edges and target nodes are returned, e.g.\nthe statement `edge.mainStat \u003e 0` will be in encoded url:\n\n    query=edge.mainStat%20%3E%200\n\nThe source nodes are referred to as `source`, target nodes are referred to as `target` and edges are \nreferred to as `edge`\n\n\n\tGET /{graph_schema}/api/graph/fields\n\tGET /{graph_schema}/api/health\n\n\n## Mange nodes and edges\n\n\tPOST /api/nodes/{graph_schema}\n\tGET /api/nodes/{graph_schema}/{id}\n\tPUT /api/nodes/{graph_schema}/{id}\n\tDELETE /api/nodes/{graph_schema}/{id}\n\t\n\tPOST /api/edges/{graph_schema} \n\tGET /api/edges/{graph_schema}/{source_id}/{target_id}\n\tPUT /api/edges/{graph_schema}/{source_id}/{target_id}\n\tDELETE /api/edges/{graph_schema}/{source_id}/{target_id}\n\nPOST operations expect a json body. The content should only include the field names in the graph schema.\n\nNode example:\n\n```json\n{\n  \"id\": \"lb-01\",\n  \"title\": \"lb01\",\n  \"subTitle\": \"instance:#01\",   \n  \"arc__failed\": 0.0,\n  \"arc__passed\": 0.0,\n  \"detail__role\": \"load\",\n  \"mainStat\": 0.0,\n  \"secondaryStat\": 0.0\n}\n```\n\nPUT takes query parameters with the fields to be updated and id as a path parameter.\n\nDELETE and GET do not have any query parameters. \n\n\n```bash\ncurl -s -i  -H \"Content-Type: application/json\" -X PUT \"localhost:9393/api/nodes/micro/lb-01?arc__failed=0.1?arc__passed=0.9\"\n```\n\n## Manage a complete graph\nThe api endpoints will operate on a complete graph. The POST will first\ndelete before create. For a client that have the full \"picture\" of the graph\nmodel, this is the most effective endpoint to use.\n\n    POST /api/graphs/{graph_schema}\n    DELETE /api/graphs/{graph_schema}\n\n\u003e The graph endpoints in singulars are deprecated:\n\u003e \n\u003e  POST /api/graphs/{graph_schema}\n\u003e \n\u003e  DELETE /api/graphs/{graph_schema}\n\nThe POST endpoint require a body of a list of nodes and edges, e.g.\n```json\n{\n  \"nodes\": [\n    {\n      \"id\": \"lb-1\",\n      \"title\": \"lb\",\n      \"subTitle\": \"instance:#01\",\n      \"detail__role\": \"load\",\n      \"arc__failed\": 0,\n      \"arc__passed\": 1,\n      \"mainStat\": 0,\n      \"secondaryStat\": 0\n    },\n    ....\n    \n  ],\n  \"edges\": [\n    {\n      \"source\": \"lb-1\",\n      \"target\": \"cust-svc-1\",\n      \"mainStat\": 0,\n      \"secondaryStat\": 0\n    },\n    ....\n  ]\n}\n```\n\nPlease see the `examples/graph.json` and `examples/setup_graph.sh` for a\ncomplete example.\n\n## Internal metrics\n\nInternal metrics are exposed on endpoint `/metrics`. Go metrics and nodegraph-provider specific metrics are exposed \non the endpoint in Prometheus format.\n\n## Deprecated API\t\nThe following api are deprecated: \n\n    POST /api/controller/{graph_schema}/delete-all\n\n\n## Return status\n\n- 200\n  - Successful - PUT, DELETE, GET\n- 201\n - Create successful - POST\n- 400 \n  - Not a valid json - POST\n  - Not a valid field name - POST, PUT\n- 404\n  - Object do not exist - PUT, DELETE, GET\n- 409 \n  - Object already exists - POST\n- 415\n  - Invalid value for header \"Content-Type\"\n\n\n# Get started\nInstall Grafana and datasource https://github.com/exaco/nodegraph-api-plugin.\nStart grafana to allow unsigned plugins\n\n    export GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=hamedkarbasi93-nodegraphapi-datasource ; ./bin/grafana-serve\n\nStart redis with module RedisGraph. Simple way just use docker.\n\n    docker run -p 6379:6379 redislabs/redismod\n    \nStart nodegraph-provider, configuration file is default `config.yml`\n\n    go build -o build/nodegraph-provider  *.go\n    ./build/nodegraph-provider\n    \nTo see all options \n\n    ./build/nodegraph-provider -h\n\n\nCreate a data source in Grafana with the nodegraph-api-plugin and set url to `http://localhost:9393/micro`.\nName it to `Micro`.\n\nCreate a dashboard and select the \"Node Graph\" plugin. Select the data source `Micro`.\n \nLoad the simple graph model by create nodes and edges:\n\n    ./examples/setup_test.sh\n    \nOr run the example to create a complete graph:\n\n    ./examples/setup_graph.sh\n\nIn Grafana you should now see this graph.\n\n![Initial Graph](docs/graph_1.png?raw=true \"Start graph\")\n\nAdd a new node with id `cust-svc-2`\n\n    curl -s -i  -H \"Content-Type: application/json\" -X POST localhost:9393/api/nodes/micro -d @examples/node_create.json\n\nCreate an edge between `lb-1` and `cust-svc-3` \n\n    curl -s -i  -H \"Content-Type: application/json\" -X POST localhost:9393/api/edges/micro -d @examples/edge_create.json \n\nUpdate metrics on `lb-1`\n\n    curl -s -i  -H \"Content-Type: application/json\" -X PUT \"localhost:9393/api/nodes/micro/book-svc-1?mainStat=$RANDOM\u0026secondaryStat=$RANDOM\u0026arc__failed=0.1\u0026arc__passed=0.9\"\n\nUpdate metrics on edge between `lb-1` to `cust-svc-1\n    \n    curl -s -i  -H \"Content-Type: application/json\" -X PUT \"localhost:9393/api/edges/micro/lb-1/cust-svc-1?mainStat=$RANDOM\u0026secondaryStat=$RANDOM\"\n\nYou should now see something like this.\n\n![Updated Graph](docs/graph_2.png?raw=true \"Updated graph\")\n\nDelete the whole graph\n\n    curl -s -i  -H \"Content-Type: application/json\" -X DELETE \"localhost:9393/api/graph/micro\"\n\n\n# Build docker \nUse the Dockerfile in the root directory of the project\n\n     docker build --tag nodegraph-provider .\n     \nTo run the image a config file must be mounted\n    \n     docker run -p 9393:9393 -v $(pwd)/config_tempo.yaml:/app/config.yaml nodegraph-provider\n    \nEnvironment variables can be set to override defaults and config file\n\n     docker run -p 9393:9393 -v $(pwd)/config_tempo.yaml:/app/config.yaml -e NODEGRAPH_PROVIDER_PORT=9393 -e NODEGRAPH_PROVIDER_REDIS_HOST=localhost -e NODEGRAPH_PROVIDER_REDIS_PORT=6379  nodegraph-provider \n\n# Demo examples\nCheckout the [tempo_trace_aggregation](https://github.com/opsdis/tempo_trace_aggregation) project\nwhere nodegraph-provider is used to create a \"dynamic service map\" based on\naggregated traces stored in [Grafana Tempo](https://github.com/grafana/tempo).\n\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopsdis%2Fnodegraph-provider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopsdis%2Fnodegraph-provider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopsdis%2Fnodegraph-provider/lists"}