I am using the query below to gather all the request IDs of when an error occurs when calling an api. It provides a list of request ids (over 1000 per hour) in a table format.
index=prod_diamond sourcetype=CloudWatch_logs source=*downloadInvoice* AND *error* NOT ("lambda-warmer") | fields error.requestId | rename error.requestId as requestId | stats values by requestId
I want to then pass all the values gained from the query into a new query to find what device each requestId is coming from. The new query would look something like this.
*requestId_1* OR *requestId_2* OR ....requestId_1000* *ChannelName* *lambda*
This query will then be used to find the frequency of each device this error is occurring on.
Is there a way to pass all the values retrieved from the first query into the second query within that format?
Please help 🙂
Hi
You could try this
<your real query which are using those regIds>
[ search index=prod_diamond sourcetype=CloudWatch_logs source=*downloadInvoice* AND *error* NOT ("lambda-warmer")
| fields error.requestId
| rename error.requestId as requestId
| dedup requestId
| format ]
Usually it's better to try replace those sub queries by stats etc. as sub queries and joins has serious limitations about returned event counts and time outs. Especially your *<TEXT>* search parameters are not good in any way. Those prevent splunk to use it's indexed fields and other query optimisations. Also NOT is no good way to use.
There are several .conf presentations and answers in community how to do that.
r. Ismo
Hi @isoutamo
Thank you for the assistance 🙂 Your query works 🙂
However I need to edit the format that is returned from the first query.
Currently the format is
( requestId="jjadjdfjjedd_jehdfjdjfhj" ) OR ( requestId="jgjfnfdn_jrhfjdbfd" )....
Is there a way to change the search to something less specific? Such as
(*jjadjdfjjedd_jehdfjdjfhj*) OR (*jgjfnfdn_jrhfjdbfd*) .....
As I need to find all events that include the requestId, not just when it is specific to that variable.
Thank you again,
Callum
Just replace in sub search the latest lines
| dedup requestId
| format
with
| dedup requestId
| rename requestId as search
| format
index=prod_diamond sourcetype=CloudWatch_logs source=*downloadInvoice* AND *error* NOT ("lambda-warmer") | fields error.requestId | rename error.requestId as requestId | stats values by requestId
|join type=inner requestId
[search (second_query for example : "*ChannelName*" "*lambda*")]
Hi @marysan
I have tried to implement your solution but have no luck, do I substitute the "second_query for example" text for something else?
Thanks,
Callum
No
this is correct form:
[search "*ChannelName*" "*lambda*")]