DataDog / datadogpy

The Datadog Python library
https://datadoghq.com/
Other
606 stars 303 forks source link

Template variables not detected in API /api/v1/graph/embed #731

Open ricardojlrufino opened 1 year ago

ricardojlrufino commented 1 year ago

Describe the bug Template variables not detected in API /api/v1/graph/embed Using a more complete "graph_json", not detect: template_variables

Working code:

graph_json = {
    "requests": [{
        "q": "avg:jvm.non_heap_memory{env:$env,service:$service}"
    },
    {
        "q": "max:jvm.non_heap_memory{env:$env,service:$service}"
    }],
    "viz": "timeseries",
    "events": []
}

graph_json = json.dumps(graph_json)

response = api.Embed.create(
    graph_json=graph_json,
    timeframe="1_hour",
    size="medium",
    legend="no"
)

But if a use JSON exported form, Dashboard -> Edit Widget -> JSON

like>

graph_json = {
    "viz": "timeseries",
    "requests": [
        {
            "style": {
                "palette": "grey",
                "type": "dashed",
                "width": "normal"
            },
            "type": "line",
            "response_format": "timeseries",
            "queries": [
                {
                    "data_source": "metrics",
                    "name": "query1",
                    "q": "max:jvm.heap_memory{env:$env,service:$service}"
                },
                {
                    "data_source": "metrics",
                    "name": "query2",
                    "q": "min:jvm.heap_memory{env:$env,service:$service}"
                }
            ]
        },
        {
            "style": {
                "palette": "warm",
                "type": "solid",
                "width": "thin"
            },
            "type": "line",
            "response_format": "timeseries",
            "queries": [
                {
                    "data_source": "metrics",
                    "name": "query1",
                    "q": "max:jvm.heap_memory_max{env:$env,service:$service}"
                }
            ]
        },
        {
            "style": {
                "palette": "grey",
                "type": "solid",
                "width": "normal"
            },
            "type": "line",
            "response_format": "timeseries",
            "queries": [
                {
                    "data_source": "metrics",
                    "name": "query1",
                    "q": "avg:jvm.heap_memory{env:$env,service:$service}"
                }
            ]
        }
    ]
}

Not detect template variables ! Returns: {'embed_id': 'XX', 'template_variables': [ ], 'html': ".........."}

Expected behavior API must need 'template_variables'

Screenshots I get JSON from image

Environment and Versions (please complete the following information): A clear and precise description of your setup: Python 3.8 certifi==2022.6.15 charset-normalizer==2.1.0 datadog==0.44.0 idna==3.3 requests==2.28.1 urllib3==1.26.11

Additional context Add any other context about the problem here.

github-actions[bot] commented 1 year ago

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.

sambarnes commented 2 months ago

@ricardojlrufino you ever figure this out? lol