CTX Blank values using {{ctx.results.0.hits.hits.0._source.resource.service.name}}

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}}
:arrow_right:Body:{{_source.body}} \n
:arrow_right:Service Name: {{_source.resource.service.name}} \n
:arrow_right:Span ID: {{_source.spanId}} \n
:arrow_right:Trace ID: {{_source.traceId}} \n
{{/ctx.results.0.hits.hits}} \n
:arrow_right:Full Result:{{ctx.results}}",

What am I doing wrong?

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”.

Hi @Patryk1 , thanks for the reply. Currently, the default name on the dashboard is this one. I’m attaching some screenshots:


Greetings!

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

@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