从InfluxDB使用标签值检索数据,返回空值。

huangapple go评论92阅读模式
英文:

Fetching data from influxDB using tag value returning null values

问题

从我的脚本中,我将所有的遥测数据发送到Influx DB,并从Grafana中获取它们。我正在尝试使用一个变量来过滤值,这个变量是我使用标签值创建的。但它获取到了0值,但对于其他标签却有效。请检查以下详细信息。

使用以下方式获取所有遥测数据:http://localhost:8086/query?db=ApiGatewayManagement&q=SELECT * FROM JMeter_Result

上述查询的输出:

{
"results": [
{
"statement_id": 0,
"series": [
{
"name": "JMeter_Result",
"columns": [
"time",
"ScenarioID",
"errorCount",
"httpstatuscode",
"receivedBytes",
"requestName",
"responseMessage",
"responseTime",
"responsecode",
"samplecount",
"sentBytes",
"status"
],
"values": [
[
"2023-02-23T15:54:51.529Z",
"ambratest_sprint_01",
0,
"200",
7978228,
"T01_LaunchApplication",
"Number of samples in transaction : 1, number of failing samples : 0",
6673,
"200",
1,
7000,
"Success"
],
[
"2023-02-23T15:54:58.315Z",
"ambratest_sprint_01",
1,
"401",
1565,
"T02_Login",
"Number of samples in transaction : 2, number of failing samples : 1",
570,
"401",
1,
1168,
"Failure"
],
[
"2023-02-23T16:04:38.904Z",
"ambratest_sprint_02",
0,
"200",
7978237,
"T01_LaunchApplication",
"Number of samples in transaction : 1, number of failing samples : 0",
9591,
"200",
1,
7000,
"Success"
],
[
"2023-02-23T16:04:48.635Z",
"ambratest_sprint_02",
0,
"200",
10923,
"T02_Login",
"Number of samples in transaction : 6, number of failing samples : 0",
1942,
"200",
1,
3518,
"Success"
]
]
]
}
]
}
}

我正在尝试创建一个使用以下方式获取的过滤变量:
http://localhost:8086/query?db=ApiGatewayManagement&q=SHOW TAG VALUES FROM "JMeter_Result" WITH KEY="ScenarioID"

上述查询的输出为null值:

{
"results": [
{
"statement_id": 0
}
]
}

但对于requestName却有效:

http://localhost:8086/query?db=ApiGatewayManagement&q=SHOW TAG VALUES FROM "JMeter_Result" WITH KEY="requestName"

输出:

{
"results": [
{
"statement_id": 0,
"series": [
{
"name": "JMeter_Result",
"columns": [
"key",
"value"
],
"values": [
[
"requestName",
"T01_LaunchApplication"
],
[
"requestName",
"T02_Login"
]
]
}
]
}
]
}

我在这里有什么遗漏吗?

英文:

From my script I am sending all my telemetry data to influx DB and fetching them from Grafana. I am trying filter the values using a variable which I am creating using tag values. But it is fetching 0 values but it is working for other. Please check below details.

Fetching all the telemetry data using : http://localhost:8086/query?db=ApiGatewayManagement&q=SELECT * FROM JMeter_Result

Output from above query:

{
    "results": [
        {
            "statement_id": 0,
            "series": [
                {
                    "name": "JMeter_Result",
                    "columns": [
                        "time",
                        "ScenarioID",
                        "errorCount",
                        "httpstatuscode",
                        "receivedBytes",
                        "requestName",
                        "responseMessage",
                        "responseTime",
                        "responsecode",
                        "samplecount",
                        "sentBytes",
                        "status"
                    ],
                    "values": [
                        [
                            "2023-02-23T15:54:51.529Z",
                            "ambratest_sprint_01",
                            0,
                            "200",
                            7978228,
                            "T01_LaunchApplication",
                            "Number of samples in transaction : 1, number of failing samples : 0",
                            6673,
                            "200",
                            1,
                            7000,
                            "Success"
                        ],
                        [
                            "2023-02-23T15:54:58.315Z",
                            "ambratest_sprint_01",
                            1,
                            "401",
                            1565,
                            "T02_Login",
                            "Number of samples in transaction : 2, number of failing samples : 1",
                            570,
                            "401",
                            1,
                            1168,
                            "Failure"
                        ],
                        [
                            "2023-02-23T16:04:38.904Z",
                            "ambratest_sprint_02",
                            0,
                            "200",
                            7978237,
                            "T01_LaunchApplication",
                            "Number of samples in transaction : 1, number of failing samples : 0",
                            9591,
                            "200",
                            1,
                            7000,
                            "Success"
                        ],
                        [
                            "2023-02-23T16:04:48.635Z",
                            "ambratest_sprint_02",
                            0,
                            "200",
                            10923,
                            "T02_Login",
                            "Number of samples in transaction : 6, number of failing samples : 0",
                            1942,
                            "200",
                            1,
                            3518,
                            "Success"
                        ]
                    ]
                }
            ]
        }
    ]
}

And I am trying to create a filter variable using
http://localhost:8086/query?db=ApiGatewayManagement&q=SHOW TAG VALUES FROM "JMeter_Result" WITH KEY=" ScenarioID"

I am getting null value: (output of the above)

{
    "results": [
        {
            "statement_id": 0
        }
    ]
}

But same work for requestName

http://localhost:8086/query?db=ApiGatewayManagement&q=SHOW TAG VALUES FROM "JMeter_Result" WITH KEY="requestName"

O/P:

{
    "results": [
        {
            "statement_id": 0,
            "series": [
                {
                    "name": "JMeter_Result",
                    "columns": [
                        "key",
                        "value"
                    ],
                    "values": [
                        [
                            "requestName",
                            "T01_LaunchApplication"
                        ],
                        [
                            "requestName",
                            "T02_Login"
                        ]
                    ]
                }
            ]
        }
    ]
}

What I am missing here ?

答案1

得分: 0

不见您查询中的任何问题,但似乎 ScenarioID 与标签无关,因此您得到 null 值。

如果您查询以下内容并且它在列表中返回 ScenarioID,那么您将获得结果,但如果它没有返回,您将观察到您发布的结果。在第二种情况下,您需要更改输入逻辑 Influx DB 并将 ScenarioID 作为标签。

http://localhost:8086/query?db=ApiGatewayManagement&q=SHOW TAG KEYS

英文:

Don't see issue with any of your query, but it seems ScenarioID is not associated with tag, because of which you are getting null value.

if you query the following and if it return ScenarioID in the list then you will get the result but if it not then you will observe the result which you posted. And in second case you need to change the input logic influx DB and make ScenarioID as the tag.

http://localhost:8086/query?db=ApiGatewayManagement&q=SHOW TAG KEYS

huangapple
  • 本文由 发表于 2023年2月26日 23:01:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/75572846.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定