blk
November 15, 2024, 9:02am
1
Describe the issue :
I have the following query with the following result
{
“_shards”: {
“total”: 1,
“failed”: 0,
“successful”: 1,
“skipped”: 0
},
“hits”: {
“hits”: [
{
“_index”: “test”,
“_source”: {
“spanId”: “4b61492ba”,
“traceId”: “3fff76dbd529c1a4deebb8e636a”,
“resource”: {
“service.name”: “test.test”
},
“body”: “Processing saleability.HIE_CRE_NodeTopDown, #100 record(s)”
},
“_id”: “1W0DL5MBz8YSiFzRSp-E”,
“_score”: 0
}
],
“total”: {
“value”: 18,
“relation”: “eq”
},
“max_score”: 0
},
“took”: 1,
“timed_out”: false
}
I’m trying to get the value {{ctx.results.0.hits.hits.0._source.resource.service.name}} but it returns a blank value.
I have tried to extract other items from the query and it does return the values for example BODY, SPAN ID TRACE ID, but service.name is blank
{{#ctx .results.0.hits.hits}}
Body: {{_source.body}} \n
Service Name: {{_source.resource.service.name}} \n
Span ID: {{_source.spanId}} \n
Trace ID: {{_source.traceId}} \n
{{/ctx.results.0.hits.hits}} \n
Full Result: {{ctx.results}}",
What am I doing wrong?
Patryk1
November 16, 2024, 6:21pm
2
Hi @blk , I believe this field is problematic because it uses a dot and is later accessed with the dot notation, and it likely causes misinterpretation. Not sure if there is a simpler fix, but you could try renaming it to “service_name”.
blk
November 17, 2024, 3:13pm
3
Hi @Patryk1 , thanks for the reply. Currently, the default name on the dashboard is this one. I’m attaching some screenshots:
Greetings!
Patryk1
November 24, 2024, 10:42pm
4
Hi @blk , apologies for the later reply.
If this is still an issue. It appears to be a Mustache limitation. I came across the following workaround:
In your scenario you may try something similar to this:
"{{#ctx.results.0.hits.hits}}\n {{#_source}}\n →Body: {{body}}\n →Service Name: {{#resource}}{{service.name}}{{/resource}}\n →Span ID: {{spanId}}\n →Trace ID: {{traceId}}\n {{/_source}}\n{{/ctx.results.0.hits.hits}}"
Let me know if this helped.
1 Like
blk
December 4, 2024, 11:48am
5
@Patryk1 Hi patrik, Thank you very much for the reply, I have tried it and it worked.
I will keep this in mind for other items, thanks for the help