Hi All,
I have a requirement, where I need to show Query Result displayed to Panel Title.
index=foo
|timechart count as devAppCount
| eval devAppC=10*devAppCount
| table devAppC
Now I want to show the result of devAppC to Panel Title in UI.
Please help me.
Thanks
Anantha.
Hi @Anantha123 ,
Put this query inside a hidden panel/row. On search done action, set a token to the `devAppcz value and use that token as panel title.
Try the below code,
<row depends="$hidden$">
<panel>
<table>
<search>
<query>index=foo |timechart count as devAppCount | eval devAppC=10*devAppCount | head 1 | table devAppC</query>
<earliest>-1h@h</earliest>
<latest>now</latest>
<done>
<set token="panel_title">$result.devAppC$</set>
</done>
</search>
</table>
</panel>
</row>
<row>
<panel>
<title>$panel_title$</title>
<table>
<search>
<query>|makeresults | eval title="$panel_title$" | table title</query>
<earliest>-1d@d</earliest>
<latest>now</latest>
</search>
</table>
</panel>
</row>
Accept the answer if it helps.
I tried this, but getting "$result.devAppC$" as a result but not value.
Does your query return only one result? If it returns more than one result do you take click input from the user?
It gives one result , but varies depending on customer choosen.
What happenes when you have more than 1 value in the result? What should be in the title? The first value or the last?
Hi @Anantha123 ,
Put this query inside a hidden panel/row. On search done action, set a token to the `devAppcz value and use that token as panel title.
Try the below code,
<row depends="$hidden$">
<panel>
<table>
<search>
<query>index=foo |timechart count as devAppCount | eval devAppC=10*devAppCount | head 1 | table devAppC</query>
<earliest>-1h@h</earliest>
<latest>now</latest>
<done>
<set token="panel_title">$result.devAppC$</set>
</done>
</search>
</table>
</panel>
</row>
<row>
<panel>
<title>$panel_title$</title>
<table>
<search>
<query>|makeresults | eval title="$panel_title$" | table title</query>
<earliest>-1d@d</earliest>
<latest>now</latest>
</search>
</table>
</panel>
</row>
Accept the answer if it helps.
Hi @Anantha123 ,
I have updated my answer.
please answer the comments from @sandeepmakkena and @arjunpkishore5 , so that we can provide better solution.
Thanks Gaurav . This worked. Actly I aslo tried the same code to initiate the token but was trying to get the value from same Panel. This has to be obtained by different panel (hidden as you mentioned) . Thanks for the help. Wish we had a solution to get token value from same panel .
Thanks
Anantha.
Hi,
It is also possible, without hidden panel
If your search is taking time to execute, so till your search execution is not completed, you will see the token variable as panel title.
<row>
<panel>
<title>$panel_title$</title>
<table>
<search>
<query>index=foo |timechart count as devAppCount | eval devAppC=10*devAppCount | head 1 | table devAppC</query>
<earliest>-1h@h</earliest>
<latest>now</latest>
<done>
<set token="panel_title">$result.devAppC$</set>
</done>
</search>
</table>
</panel>
</row>