OMS Query fixing

%3CLINGO-SUB%20id%3D%22lingo-sub-652288%22%20slang%3D%22en-US%22%3EOMS%20Query%20fixing%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-652288%22%20slang%3D%22en-US%22%3E%3CP%3Ewhile%20running%20this%20Query%20I'm%20getting%20search%20and%20union%20error%20how%20to%20resolve%20this%20%3F%26nbsp%3B%3C%2FP%3E%3CP%3Efor%20Alert%20agent%20stopped%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEvent%20%7C%20search%20%22AL%20Agent%22%20%7C%20search%20%22stop*%22%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-652288%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Log%20Analytics%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-652711%22%20slang%3D%22en-US%22%3ERe%3A%20OMS%20Query%20fixing%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-652711%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F337292%22%20target%3D%22_blank%22%3E%40vicky2019%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDoing%20a%20search%20is%20great%20to%20find%20some%20data%20but%20isn't%20good%20for%20a%20query%20in%20the%20long%20term.%26nbsp%3B%20In%20example%20one%20below%2C%20we'd%20use%20%3CEM%3Esearch%3C%2FEM%3E%20to%20find%20the%20%22AL%20agent%22%2C%20I%20used%20%3CEM%3Elimit%3C%2FEM%3E%20to%20just%20get%20just%20ten%20random%20rows%20with%20that%20data%20(for%20testing%2C%20that%20should%20be%20enough).%26nbsp%3B%20Then%20imagine%20you%20see%20that%20%22AL%20Agent%22%20is%20in%20the%20'source'%20column%20you%20can%20then%20use%20a%20%3CEM%3Ewhere%3C%2FEM%3E%20operator%20to%20look%20at%20that%20specific%20value%20-%20see%20example%20two.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%2F%2F%20example%20one%3CBR%20%2F%3EEvent%20%0A%7C%20search%20%22AL%20Agent%22%20%0A%7C%20limit%2010%0A%3CBR%20%2F%3E%2F%2F%20example%20two%0AEvent%20%0A%7C%20where%20Source%20%3D%3D%20%22AL%20Agent%22%0A%7C%20limit%2010%20%0A%3C%2FPRE%3E%0A%3CP%3EYou%20can%20then%20do%20the%20same%20to%20find%20out%20where%20%22stop%22%20occurs%20and%20then%20use%20that%20(in%20this%20pretend%20scenario%20lets%20assume%20its%20found%20in%20%22Message%22%3A%3C%2FP%3E%0A%3CPRE%3EEvent%20%0A%7C%20where%20Source%20%3D%3D%20%22AL%20Agent%22%20and%20Message%20%3D%3D%20%22Stop%22%0A%7C%20limit%2010%20%3C%2FPRE%3E%0A%3CP%3E%3CSTRONG%3ETip%3C%2FSTRONG%3E%2C%20if%20you%20don't%20know%20what%20table%20a%20string%20is%20in%2C%20you%20can%20use%20this%20-%20which%20will%20shows%20what%20Tables%20(like%3A%20Events)%20the%20string%20appears%20in%20and%20the%20count.%26nbsp%3B%20Use%20this%20sparingly%20as%20its%20very%20expensive%20(time%20and%20processing%20power)%2C%20ideally%20over%20a%20small%20time%20window%20e.g.%20less%20than%2024hrs.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%20search%20%22Agent%22%20%0A%7C%20summarize%20count()%20by%20%24table%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

while running this Query I'm getting search and union error how to resolve this ? 

for Alert agent stopped

 

 

Event | search "AL Agent" | search "stop*"

1 Reply
Highlighted

@vicky2019 

 

Doing a search is great to find some data but isn't good for a query in the long term.  In example one below, we'd use search to find the "AL agent", I used limit to just get just ten random rows with that data (for testing, that should be enough).  Then imagine you see that "AL Agent" is in the 'source' column you can then use a where operator to look at that specific value - see example two.

 

// example one
Event | search "AL Agent" | limit 10
// example two Event | where Source == "AL Agent" | limit 10

You can then do the same to find out where "stop" occurs and then use that (in this pretend scenario lets assume its found in "Message":

Event 
| where Source == "AL Agent" and Message == "Stop"
| limit 10 

Tip, if you don't know what table a string is in, you can use this - which will shows what Tables (like: Events) the string appears in and the count.  Use this sparingly as its very expensive (time and processing power), ideally over a small time window e.g. less than 24hrs.  

 

 search "Agent" 
| summarize count() by $table