How to get alert's query output in logic app? - azure-logic-apps

I am trying to get an output of the query which has triggered an alert in the logic app ( to parse it and send an email to specific receiver).
I can't run the query itself in the logic app, I have to get result from an allert.
I'm defining the logic app, specifying first step as When HTTP request is received (I provided webhook URL in an alert accordingly) and different input schemas from https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-non-common-schema-definitions (expected to have it working with monitoringService = Log Alerts V1 – Metric) but ending up with not having SearchResult.tables property in received JSON.
The query just aggregates some data and condition is to trigger an alert when num rows > X, so in addition to have triggered alert, I need to receive that aggregated data in my email. All guidances refer to Azure Alert + Logic App, however I am stuck in Step 1 - Logic App receives JSON without any query output related data like SearchResult.tables property.
what am I missing? TIA!

Related

Using ID's from previous request in new request

I have used Postman to extract a number of ID's from a request. Now I would like to use those ID's in a new series of requests using Postman. I can't figure out how to do this, does anyone know?
There are several hundreds of ID's and below are some examples that I can see in the console (but they do not appear in the request Body)
(100) [373894, 373893, 373467, 373459, 372712, …]
0: 373894
1: 373893
2: 373467
3: 373459
I would like to use postman to send new requests for all these ID's where I would like to fill the brackets with the ID's in the request URL that now looks like this:
https://app.rule.io/api/v2/campaigns/{{}}/statistics
I've tested the ID's one at a time and they work fine but I would like to run them all to then collect the data and send it to Google Data Studio. (background is that I'm trying to send campaign data from an e-mail marketing tool into Google Data Studio and combine it with website data)
Postman is able to run user-defined test scripts after the call performed. So you could define an array variable, add an ID each time you obtain it. And then, use that array variable to make a call with the whole bunch of IDs you have.
Take a look this blog: https://blog.postman.com/extracting-data-from-responses-and-chaining-requests/

protoPayload vs jsonPayload in logging

The log entries of my app result in jsonPayload while the gae request log entries use protoPayload. Just like in protoPayload, I added a requestId in my logging that shows up in jsonPayload. However, when using the log viewer where "Show entries from same request" action, I don't see my log entries since the filter uses protoPayload.requestId="xyz". I tried to use an or condition with jsonPayload.requestId="xyz" but that didn't help. Ideally I wouldn't even want to manually edit the clause as it will be painful to do everytime. Seems like per the following documentation, the requestId in each of these types of payloads don't map to the same underlying bigquery field.
https://cloud.google.com/logging/docs/export/bigquery
There is also a "trace" field directly on the log entry and that is same for all the related logs. However, there is no field called trace to search. Doing a text search does return all the entries. While this works, again the UX is bad as it requires first drilling down to the request log entry, copying the trace value and then doing a query.
So, are there any other options to tie the request log entry with the rest of the app log entries for that request easily?
There is a field called "trace" that is on the log entry which works. I think I was confused with the "traceId" within the protoPayload. Note that to get the "trace" field to show up with json payload, the field name should be "logging.googleapis.com/trace"

When is new Gmail API History ID generated

I am trying to design an algorithm to maintain a list of new INBOX messages using a combination the watch()/push notification, with the user.history and user.messages gmail apis. HistoryID documentation is unclear.
https://developers.google.com/gmail/api/guides/sync#partial
indicates
"You can also use push notifications to trigger partial synchronization in real-time and only when necessary, thereby avoiding needless polling." -- My question is HOW?
Which event on the email account triggers an incremented HistoryID?
If I guess HistoryID I get in the push notification the latest historyId of the label specified, then I should be able to use that HistoryID as the starting HistoryId in the User.History.List call, but when I do I just get an json response which is another higher HistoryID. So, if I'm specifying messagesadded and watching INBOX, why is the call to History API with the most current HistoryID returning no HistoryList objects?
I have read Gmail API users.watch - no details for historyId and Gmail History list is not giving complete data
and I'm unclear as to how to design the algorithm to use push notifications in conjunction with the other apis to do a partial sync to maintain a running inventory on new INBOX messages, as per the documentation.
this issue really sad, google just send historyId with empty history list. But why cant add emailId or property that this history binds with new message arrived?
To solve this problem u need remember time when u last time fetch email messages with total counter messages in Inbox, next, when u get google pub/sub message and it has empty history object - u need get new total counter of messages in Inbox label - if there is differences - next what u need is fetch email messages using:
or
max count value = differences between of total counter messages,
means add query to get messages by max result
or
using date time from your last update - means add query to get messages by date time.
Really bad that google make such bad implementation for pub sub for new messages.

How to modify firebase database so that i can set a read or unread status

I need to show the count of unread messages from firebase in the notification bell.
I am done with displaying all contents in my collection in my web application.But when a new message arrives i need to give a feedback to user by showing the unread message count in notification bell .From my understanding,for that i need to set a read/unread status in firebase collection.Is there any alternative way for showing the count of unread messages in my React Web Application?
i am using firebase package of npm for displaying messages.
Below is the sample data in my firebase collection.
name:"John Doe",
message:"you got a new appointment"
i am new to firebase.Please help me with some logic to sort out this problem.
If I understand correctly, you would want to use a status flag (read: boolean), unless you would not mind writing all new messages to a particular path and moving them to another path after it is read.
Something like below
/user/unread-msg => all new messages come here
/user/read-msg => messages are moved here after being read.
This I believe would be less efficient than using a simple flag.
You could use a firebase cloud function to maintain the count of child elements in a particular path like /user/unread-msg or /user/read-msg so that you don't have to download the entire data to get the count.
Refer the sample code at https://github.com/firebase/functions-samples/tree/master/child-count

Routing with http calls in Angular 2

I am looking for the best way to route between my components in Angular 2. In my application I go from page to page by submitting a form:
Page A displays a form and a submit button to go to next step,
Data filed by the user in page A form are used to call a backend action using ajax,
Page B shows the result of the ajax call and a new form to go to next step (page C)...
At each step the backend can return an error and we either go back to previous page, or display an error page (fatal error).
I see two simple options to do the ajax call:
Component A only displays the form and forward the input parameters to component B. Component B run the ajax call and display the result.
OR component A run the ajax call with the input parameters he has and forward the result to component B for display. In case of error component A redisplay itself.
The problem with option 1 is that in case of error the backend will respond with the page A business model and an error message. Component B will have to forward the result to component A so page A can be redisplayed.
The problem with option 2 is that component A has part of the business logic of component B which is not really good for component encapsulation.
My question is: is there a good design pattern to do this? Should I use an intermediate component for example?
Thank you for your help.
I would move all ajax calls to parent component and keep all the data there too, assuming forms are independent. So workflow would be like this:
cP(arent) go to cA
cA - show form, send data to cP
cP - send A data via ajax, go to cB
cB - show form, send data to cP
cP - (got error for A data), send B data via ajax, go to cC
cC - show form, notify user there was an error with form A, offer user to go back now, or finish step C and do A later, send data to cP
cP - (got fatal error for B data), don't send C data via ajax, save data to localStorage?, tell user to try later...
...etc. It's more user friendly and you can show pages/forms as needed.
If forms depend on each other, I'd still keep the ajax and data in parent, and display them if/when server responds. But I recommend you design them do be independent, or you can play some elevator music while user waits (;

Resources