Print custom message when there is no data in table return by kusto query - azure-data-explorer

I am working on a dashboard, where in backend Kusto query are running and plot a graph on dashboard based on the results.
I am trying to print a custom message like,
| extend CustomColumn=iff(isempty(expectedExpiration),"Expiration data is not available for this ",expectedExpiration)
i tried isempty, isnull, isNaN function as well but I am not getting this custom message as an output.
Can you help in finding what is going wrong here or I am missing something?
Explained in prob statement

Related

Cloud Firestore indexes for collection groups with multiple where clauses

I have written a function that runs every x amount of time and changes a field in a document in cloud firestore if a specific condition applies. However, the function fails due to the function needing an index. I don't know what index I need.
This is the line that gives the error.
const snapshot = db.collectionGroup('people').where('dateEndFunctional', '<', today).where('state', '==', 'active').get()
.then(function(querySnapshot){
querySnapshot.forEach(function(doc){
This is the error message I'm getting
Error: 9 FAILED_PRECONDITION: The query requires an index. You can create it here: https://console.firebase.google.com/v1/r/project/fmis-online-dev/firestore/indexes?create_composite=Ck5wcm9qZWN0cy9mbWlzLW9ubGluZS1kZXYvZGF0YWJhc2VzLyhkZWZhdWx0KS9jb2xsZWN0aW9uR3JvdXBzL3Blb3BsZS9pbmRleGVzL18QAhoJCgVzdGF0ZRABGhUKEWRhdGVFbmRGdW5jdGlvbmFsEAEaDAoIX19uYW1lX18QAQ
If I follow the link, I always get an error, like the image below.
It states:
Loading failed.
An error occured while loading [link]. Try again.
However, eery time I try again, it gives the same error.
I have tried to create a combined index for both of the fields the where clauses are testing, as well as creating two seperate indexes for each of the fields. Both resulted in the same error. What index do I need for this function to properly work?
Thanks in advance for your help!
The link should work, just make sure you are logged into the right account on google cloud.....
For the people that want the answer:
A collection group index on people with state ASC and dateEndFunctional ASC
I don't know why it didn't work before, because I think I have tried this. Perhaps the order of fields matter. The link should take care of that

Why is the same query syntax not supported in Log Analytics and Application Insight Logs?

I am trying to figure out why the same query is not valid in both a Log Analytics and Application Insights workspace.
I've been working on creating a cross-resource query and when I write the syntax in Log Analytics it has a syntax error around the workspace operator. It is successful when I do the same thing in an Application Insights query.
The query looks like this:
union
workspace("DefaultWorkspace-b432aa91-rrrr-qqqq-zzzz-aabbba7e8f42-WUS2").SecurityEvent
,workspace("DefaultWorkspace-fca02198a-aaaa-eeee-cccc-aaad9fbf7302-EUS").SecurityEvent
| count
Since in both workspaces it references other workspaces, I would think it would be portable if queried under the same tenant (which I am). In Azure Log Analytics it gives me the error:
Unknown function: 'workspace'.
I am running these in the Azure portal at the moment.
Can you try adding a space after the comma? This query is working for my own workspaces.
union
workspace("DefaultWorkspace-b432aa91-rrrr-qqqq-zzzz-aabbba7e8f42-WUS2").SecurityEvent
, workspace("DefaultWorkspace-fca02198a-aaaa-eeee-cccc-aaad9fbf7302-EUS").SecurityEvent
| count
This is not a direct answer, but suggestions.
As far as I know, only if the query missing table name, then it will cause the error "Unknown function: 'workspace'.". Like below:
So first, make sure in your query, you are adding table name after workspace("xxx"). I notice that in your query, you're using the correct syntax, but just want to make sure the table name is there.
Second, if you're adding table name after workspace("xxx"), and still get this error. You can try just use the query below to check if the workspace("xxx") works:
workspace("adsmit-test").Heartbeat
| count
Please feel free to let me know if you still have the issue.
I tried the same statement 2 weeks later in both an Application Insights and Log Analytics and it works in both.

https://graph.microsoft.com/v1.0/deviceAppManagement/managedAppRegistrations filter on bundleId or packageId

I am trying to retrieve info from intune via GraphApi.
Want to filter on bundleId or packageId field (located under appIdentifier).
But I can't seem to find a way to do this.
Target result is :
userId,os_type (based on either #odata.type or packageId/bundleId).
Step further is that i want to identify certain apps by filtering on for example startswith(packageId,'com.microsoft').
I have tried combinations on "/deviceAppManagement/managedAppRegistrations?$filter=startswith(bundleId,'com.m'). But I keep on ending up on "invalid filter clause" whenever i want to execute a filter action.
Trying to recover from microsoft documentation if any filtering is possible on this part of graph seems impossible.
Currently we are using power automate to retrieve data and that works if we don't filter / select.
screenshot of json result
Use the following filter: startsWith(microsoft.graph.iosVppApp/bundleId, 'com.microsoft')
I found a pointer at this reddit post: https://www.reddit.com/r/Intune/comments/cxkwm3/using_graph_to_show_all_apps_from_one_vpp_token/

How to query one field then order by another one in Firebase cloud Firestore?

I'm struggling to make a (not so) complex query in firebase cloud firestore.
I simply need to get all docs where the id field == a given id.
Then order the results by their date and limit to 10 results.
So this is my current situation
db.firestore().collection('comments')
.where("postId",'==',idOfThePost)
.orderBy('date','asc').limit(10).get().then( snapshot => {
//Nothing happens and the request wasn't even been executed
})
I can get the result only if i don't use the orderBy query but i have to process this sorting for the needs of my application.
Someone has an idea to help me to fix this ?
thanks
You can do this by creating an Index in the firestore.
The first field of the index should be the equality field and the second field of the index should be the order by field.
Given your problem, you would need the following index:
first field: postId, 'asc'
second field: date, 'asc'
Please check the doc. It says
However, if you have a filter with a range comparison (<, <=, >, >=), your first ordering must be on the same field
you can try this code
db.firestore().collection('comments')
.where("postId",'==',idOfThePost)
.orderBy('postId')
.orderBy('date','asc').limit(10).get().then( snapshot => {
.....
})
My Workaround
If you're googling this you've probably realized it can't be done traditionally. Depending on your problem though there may be some viable workarounds, I just finished creating this one.
Scenario
We have an app that has posts that appear in a feed (kind of like Reddit), each post has an algorithmic score 'score' and we needed a way to get the 'top posts' from 12-24 hours ago. Trying to query sorted by 'score' where timestamp uses > and < to build the 12-24 hour ago range fails since Firebase doesn't allow multiple conditional querying or single conditional querying with an descending sort on another field.
Solution
What we ended up doing is using a second field that was an array since you can compound queries for array-contains and descending. At the time a post was made we knew the current hour, suppose it was hour 10000 since the server epoch (i.e. floor(serverTime/60.0/60.0)). We would create an array called arrayOfHoursWhenPostIsTwelveToTwentyFourHoursOld and in that array we would populate the following values:
int hourOffset = 12;
while (hourOffset <= 24) {
[arrayOfHoursWhenPostIsTwelveToTwentyFourHoursOld addObject:#(currentHour+hourOffset)];
hourOffset++;
}
Then, when making the post we would store that array under the field hoursWhenPostIsTwelveToTwentyFourHoursOld
THEN, if it had been, say, 13 hours since the post was made (the post was made at hour 10000) then the current hour would be 10013, so we could use the array-contains query to see if our array contained the value 10013 while also sorting by algorithm score at the same time
Like so:
FIRFirestore *firestore = [Server sharedFirestore];
FIRCollectionReference *collection = [firestore collectionWithPath:#"Posts"];
FIRQuery *query = [collection queryOrderedByField:#"postsAlgorithmScore" descending:YES];
query = [query queryWhereField:#"hoursWhenPostIsTwelveToTwentyFourHoursOld" arrayContains:#(currentHour)];
query = [query queryLimitedTo:numberToLoad];
Almost Done
The above code will not run properly at first since it is using a compound index query, so we had to create a compound index query in firebase, the easiest way to do this is just run the query then look at the error in the logs and firebase SDK will generate a link for you that you can navigate to and it will auto-generate the compound index for your database for you, otherwise you can navigate to firebase>database>index>compound>new and build it yourself using hoursWhenTwelveToTwentyFourHoursOld: Arrays, score: Descending
Enjoy!
same here, it is weird why can't. below is another sample. can't get the result. Hoping firebase can reply about this and update the document.
dbFireStore.collection('room').where('user_id.'+global.obj_user.user_id,'==',true).orderBy('last_update').get().then((qs)=>{
console.log(qs);
});
using other work-around solution is javascript array and array.sort()
I ran into the same issue yesterday on Android. The Callback was just not called. Today I suddenly got an error message. FAILED_PRECONDITION: The query requires an index. It even contains a URL in the error message to generate that index with one click.
It seems that if you want to use orderBy on your data, you need to create an index for that field. The index also needs to be in the correct order (DESC, ASC).
As per firestore document,
If you attempt a compound query with a range clause that doesn't map to an existing index, you receive an error. The error message includes a direct link to create the missing index in the Firebase console.
So just click that link you get in Logcat, it will be redirected to create index page, just create index. It will take some time. after enabling composite index, you will get the result as your requested query.
Stumbled across this looking for help when i found that using the orderBy function didnt work and the documentation still says it does not support it. A bit weird and unclear to be honest, because it does support it so long as you index your Firestore database. For example, this query now works fine for me having set up indexing:
const q = query(docRef, where("category", "==", 'Main'), orderBy('title', 'asc')
Indexing in Firestore
Console Log that even gives you the url to automatically create the index if you try and run with the above command.
Maybe I am missing something, or a later version of Firebase (I am using v9) simply does support it.

Yahoo YQL console not working for finanace table

I am just trying to do some test calls to the API via the yahoo YQL console : https://developer.yahoo.com/yql/console/
But when I even try to do simple calls that should work, I am getting undefined table error
When I try:
select * from yahoo.finance.quotes
It returns "No definition found for Table yahoo.finance.quotes" in the xml.
What the hell?
Thanks in advance
That's because yahoo.finance.quotes is a community data table. More details about community data tables here: http://www.datatables.org/ .In order to access this table you need to enable access to them in the console by clicking "Show Community Tables" checkbox on top-left part of the console.
Run your query after that.
Note: After you get the community tables working, if you run your YQL query, you will find you are missing a required parameter "symbol". If you want to get quote details for Facebook(FB) then you can do select * from yahoo.finance.quotes where symbol='FB'. Hope this helps

Resources