Stream analytics - Pocessing JSON with no array name - azure-eventhub

I would like to convert this array to rows using a stream analytics query containing the CROSS APPLY GetArrayElements() but this function requires an array name. Obviously there is no name. Any suggestions?
Example of JSON to parse :
{
"Alert1": {
"Site": "11109370",
"Sensor": "UPS",
"Event": "Load Not Protected",
"Time": "08-28-2019 10:39:02",
"Value": "0",
"Threshold": 0,
"Severity": "2",
"Status": "Open"
},
"Alert2": {
"Site": "11109370",
"Sensor": "UPS",
"Event": "Emergency stop",
"Time": "08-28-2019 10:39:02",
"Value": "1",
"Threshold": 1,
"Severity": "2",
"Status": "Open"
},
"Alert3": {
"Site": "11109370",
"Sensor": "UPS",
"Event": "Load Protected(UPS Coupled)",
"Time": "08-28-2019 10:39:02",
"Value": "0",
"Threshold": 0,
"Severity": "1",
"Status": "Open"
},
"Alert4": {
"Site": "11109370",
"Sensor": "UPS",
"Event": "Battery Deep Discharge Protection",
"Time": "08-28-2019 10:39:02",
"Value": "0",
"Threshold": 0,
"Severity": "1",
"Status": "Open"
},
"Alert5": {
"Site": "11109370",
"Sensor": "UPS",
"Event": "Battery Present",
"Time": "08-28-2019 10:39:02",
"Value": "0",
"Threshold": 0,
"Severity": "1",
"Status": "Open"
},
"Alert6": {
"Site": "11109370",
"Sensor": "UPS",
"Event": "Sensor Communication Error",
"Time": "08-28-2019 10:39:02",
"Status": "Close"
}
}
I tried the code below but I encountered an error :
Error : Invalid column name: 'arrayvalue'. Column with such name does not exist.
SELECT message.ArrayValue
FROM INPUT as event
CROSS APPLY GetRecordProperties(event) AS message

Your direction is right,however, i think you made a little mistake about the usage of GetRecordProperties function.
Please see the example stated in the official document,not any ArrayValue properties:
SELECT
recordProperty.PropertyName,
recordProperty.PropertyValue
FROM input as event
CROSS APPLY GetRecordProperties(event.recordField) AS recordProperty
For your situation, you could execute below sql:
SELECT
recordProperty.PropertyName,
recordProperty.PropertyValue
FROM input as event
CROSS APPLY GetRecordProperties(event) AS recordProperty
Output:
As i asked that how you want to deal with Alert1,Alert2 properties,if you want to get rid of them,then use below sql:
SELECT
recordProperty.PropertyValue.Site, recordProperty.PropertyValue.Sensor....<more your columns>
FROM input as event
CROSS APPLY GetRecordProperties(event) AS recordProperty
Output:

Related

"This property must be an Array, not an array" Error from AWS Healthlake

I'm converting Apple records data (in DSTU2 format) to R4 format.
This is the data I'm sending to healthlake server
{
"category": [
{
"text": "Vital Signs",
"coding": [
{
"system": "http://hl7.org/fhir/observation-category",
"code": "vital-signs"
}
]
}
],
"issued": "2017-03-18T00:00:00Z",
"status": "final",
"id": "49a1b0f9-34c2-472d-8b64-34447d307c56",
"code": {
"text": "Temperature",
"coding": [{ "system": "http://loinc.org", "code": "8310-5" }]
},
"encounter": { "reference": "Encounter/355" },
"subject": { "reference": "Patient/82146c45-a7cd-47ee-a5ba-8c588d4c5c9e" },
"valueQuantity": {
"code": "Cel",
"system": "http://unitsofmeasure.org",
"value": 37.6,
"unit": "Cel"
},
"resourceType": "Observation",
"meta": { "lastUpdated": "2023-01-30T09:17:54.772Z" }
}
But the healthlake server is giving me the following error
{"resourceType":"OperationOutcome","issue":[{"severity":"error","code":"processing","diagnostics":"This property must be an Array, not an array","location":["Observation.category[0]"]}]}
What does this error means and how to fix this?
PS: I'd only googled the error and could not get any leads

Google Cloud Run randomly spiking requests

I've deployed two Hasura instances via Cloud Run, but have been getting randomly spiking requests periodically for one of the containers. As far as I can see, this is not being initiated by any of our frontends, and the spikes look irregular. Weirdly enough, this issue is only happening on one of our instances.
Getting the following messages for each request:
#1:
{
"insertId": "x",
"jsonPayload": {
"type": "webhook-log",
"detail": {
"http_error": null,
"response": null,
"message": null,
"method": "GET",
"status_code": 200,
"url": "x/auth"
},
"timestamp": "2021-08-26T22:35:40.857+0000",
"level": "info"
},
"resource": {
"type": "cloud_run_revision",
"labels": {
"service_name": "x",
"configuration_name": "x",
"location": "us-central1",
"project_id": "x",
"revision_name": "x"
}
},
"timestamp": "2021-08-26T22:35:41.839935Z",
"labels": {
"instanceId": "x"
},
"logName": "x",
"receiveTimestamp": "2021-08-26T22:35:42.002274277Z"
}
#2:
{
"insertId": "x",
"jsonPayload": {
"timestamp": "2021-08-26T22:35:40.857+0000",
"detail": {
"user_vars": null,
"event": {
"type": "accepted"
},
"connection_info": {
"msg": null,
"token_expiry": null,
"websocket_id": "x"
}
},
"level": "info",
"type": "websocket-log"
},
"resource": {
"type": "cloud_run_revision",
"labels": {
"project_id": "x",
"revision_name": "x",
"service_name": "x",
"configuration_name": "x",
"location": "us-central1"
}
},
"timestamp": "2021-08-26T22:35:41.839957Z",
"labels": {
"instanceId": "x"
},
"logName": "x",
"receiveTimestamp": "2021-08-26T22:35:42.002274277Z"
}
Drawing a blank right now as to what's going on. Any advice is helpful!!
Got it! Turns out it was a few open WebSocket connections from users keeping their browser tab open.
Lesson learned!

How to loop over a GET request and do a POST every key found

Just started playing around withPostman a week ago to make life easier.
Situation :
I have a get request which returns x amount of key (Jira userstories)
What do i want to achieve :
I want to create subtask for each of the keys i get back from the GET request with Postman
The POST part on how to create the subtask is already done. My issue is specifically looping through the GET request list to create it for every story.
Any help would be much appreciated
My postman GET request :
{
"expand": "schema,names",
"startAt": 0,
"maxResults": 50,
"total": 8,
"issues": [
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "59332",
"self": "xxx",
**"key": "GRIP-502"**
},
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "58465",
"self": "xx",
"key": "GRIP-429"
},
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "56409",
"self": "xxxx",
**"key": "GRIP-338"**
},
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "55191",
"self": "xxx",
"key": "GRIP-246"
},
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "55180",
"self": "xx",
**"key": "GRIP-244"**
},
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "52783",
"self": "xx",
"key": "GRIP-104"
},
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "51641",
"self": "xxx",
"key": "GRIP-69"
},
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "51473",
"self": "xx",
"key": "GRIP-48"
}
]
}
in the first request where you get the information store the issues into a variable:
pm.environment.set("issues",pm.response.json().issues)
In the pre-request section of the POSt request you want to send use :
let array = pm.environment.get("issues")
let issue = array.pop()
pm.environment.set("issues",array)
pm.environment.set("id",issue.id) // or key what ever you want
array.length!==0?postman.setNextRequest(pm.info.requestName):null
You could write a javascript function to iterate and process each issue in your response. For example:
function createSubTask(issueId) {
console.log(`POST Subtask: ${issueId}`);
}
for (let subtask of response.issues) {
createSubTask(subtask.id)
}
You can find more help here

How to fetch API data as this. props?

I am trying to fetch data from API in react component as
{this.props.buyer && this.props.buyer[0].phone_number[0].number} - it's throwing error
Cannot read property 'number' of undefined
{this.props.buyer && this.props.buyer[0].name} - it's working fine
This is the API data
Orders: {
buyer:
},
}
[
{
"id": 2,
"name": "Qi Xiang",
"type": "Consignee",
"address": {
"id": 2,
"type": "shipping",
"street": "China China",
"city": "Beijing",
"postal_code": "34343",
"province": "23232",
"country": "CN"
},
"email": null,
"phone_number": {
"number": "323232",
"type": "Phone"
},
"id_image_url": "/api/files/24e49645-df42-4984-a
}
]
},
}
Your phonenumber is not array. You must use this:
this.props.buyer[0].phone_number.number

Why application posts on my wall marked as links?

My application creates posts on user's wall, but it's marked as link.
I see that other applications doing same thing but for some reason facebook don't mark their posts as links. Tried to find the difference between them and me in graph api explorer, and the only difference is status_type attribute (this is not even documented). Mine set to "shared_story" and in other applications is "app_created_story". Tried to set it manualy but facebook still use shared_story even if I set it to app_created_story
Data from graph api explorer (first is my application)
[{
"id": "100001302536317_168939309896943",
"from": {
"name": "Андрей Реаскович",
"id": "100001302536317"
},
"story": "Андрей Реаскович shared a link.",
"story_tags": {
"0": [
{
"id": "100001302536317",
"name": "Андрей Реаскович",
"offset": 0,
"length": 16,
"type": "user"
}
]
},
"picture": "http://external.ak.fbcdn.net/safe_image.php?d=AQBcrRQnipKHB6g6&w=90&h=90&url=http%3A%2F%2Fstatic.jackpotrush.com%2Fimages%2Fviral%2Fgames%2Fjoker_jester.png",
"link": "http://apps.facebook.com/jackrush/?ref=bonus-game",
"name": "I Won Big on a Bonus Round at Jackpot Rush!",
"caption": " ",
"description": "I Just Won 200 Coins at a Jackpot Rush Bonus Round and it Feels Amazing!",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/100001302536317/posts/168939309896943"
},
{
"name": "Like",
"link": "http://www.facebook.com/100001302536317/posts/168939309896943"
}
],
"privacy": {
"description": "Only Me",
"value": "SELF"
},
"type": "link",
"status_type": "shared_story",
"application": {
"name": "Jackrush Development",
"namespace": "jackrush",
"id": "434595133235542"
},
"created_time": "2012-11-12T08:48:18+0000",
"updated_time": "2012-11-12T08:48:18+0000",
"comments": {
"count": 0
}
},
{
"id": "100001302536317_420171444702936",
"from": {
"name": "Андрей Реаскович",
"id": "100001302536317"
},
"picture": "http://platform.ak.fbcdn.net/www/app_full_proxy.php?app=242829452408559&v=1&size=z&cksum=cd0fa7a15202d05700bf1464fd989d42&src=http%3A%2F%2Fc.cdn.blueshellgames.com%2Fs%2F%3Aac05b878%2Fmonte%2Fi%2Ffeed_story_image-logo_black.png",
"link": "http://apps.facebook.com/luckyslotsgame/?action=shareLevelUpReward&posterID=fb%3A100001302536317&k_utag=df3f4636aabab65e&levelUpToken=6553%3AsVFCJmW43zW_Nni9vBB9xg%3D%3D&level=4&refID=fb%3A100001302536317&utm_medium=viral&utm_source=levelUp",
"name": "First 5 Clickers get 150 Free Coins!",
"caption": "Андрей just reached level 4 and is giving away 150 Free Coins to celebrate!",
"description": "Play the best slots on Facebook! Get free chips daily! Unlock new slot machines and new bonus games! Don't miss out, play now!",
"icon": "http://photos-d.ak.fbcdn.net/photos-ak-snc7/v85006/51/242829452408559/app_2_242829452408559_9481.gif",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/100001302536317/posts/420171444702936"
},
{
"name": "Like",
"link": "http://www.facebook.com/100001302536317/posts/420171444702936"
},
{
"name": "Claim BONUS Coins",
"link": "http://apps.facebook.com/luckyslotsgame/?action=shareLevelUpReward&posterID=fb%3A100001302536317&k_utag=df3f4636aabab65e&levelUpToken=6553%3AsVFCJmW43zW_Nni9vBB9xg%3D%3D&level=4&refID=fb%3A100001302536317&utm_medium=viral&utm_source=levelUp"
}
],
"privacy": {
"description": "Public",
"value": "EVERYONE"
},
"type": "link",
"status_type": "app_created_story",
"application": {
"name": "Lucky Slots",
"namespace": "luckyslotsgame",
"id": "242829452408559"
},
"created_time": "2012-11-12T08:13:25+0000",
"updated_time": "2012-11-12T08:13:25+0000",
"comments": {
"count": 0
}
}]