Anomalous Google Directive turning on all devices, what may have caused this? - actions-on-google

We have been developing a Google Home action over the past weeks. Just today, an internal tester turned off a Room with a few lights, in preparation to leave the house. Roughly 15 seconds later, we see in our logs, a directive came in to seemingly turn on every device that supported the OnOff trait. This has not been double checked at this time. Suffice it to say, though, a lot of things were turned on.
See below our server logs of the original turning off of a room, followed by the unexpected and undirected command:
__INPUT_________________________________________________________
[ UTC 14:40:16 12/1/2018 ]
{
"inputs": [
{
"intent": "action.devices.EXECUTE",
"payload": {
"commands": [
{
"devices": [
{
"customData": {
"colorTemperatureRange": null,
"dimLevelRange": {
"max": 15,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "26782020"
},
{
"customData": {
"colorTemperatureRange": {
"max": 600,
"min": 0
},
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "24175054"
},
{
"customData": {
"colorTemperatureRange": null,
"dimLevelRange": null,
"onOffMode": "/on_off/"
},
"id": "23742906"
},
{
"customData": {
"colorTemperatureRange": {
"max": 600,
"min": 0
},
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "27706708"
},
{
"customData": {
"colorTemperatureRange": {
"max": 600,
"min": 0
},
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "26164657"
},
{
"customData": {
"colorTemperatureRange": null,
"dimLevelRange": null,
"onOffMode": "/on_off/"
},
"id": "26597087"
}
],
"execution": [
{
"command": "action.devices.commands.OnOff",
"params": {
"on": false
}
}
]
}
]
}
}
],
"requestId": "3392868800863712071"
}
__RESPONSE______________________________________________________
[ UTC 14:40:16 12/1/2018 ] {
"requestId": "3392868800863712071",
"payload": {
"commands": [
{
"states": {
"on": false,
"online": true
},
"ids": [
"26782020",
"24175054",
"23742906",
"27706708",
"26164657",
"26597087"
],
"status": "SUCCESS"
}
]
}
}
__INPUT_________________________________________________________
[ UTC 14:40:30 12/1/2018 ] {
"inputs": [
{
"intent": "action.devices.EXECUTE",
"payload": {
"commands": [
{
"devices": [
{
"customData": {
"colorTemperatureRange": null,
"dimLevelRange": {
"max": 15,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "26782020"
},
{
"customData": {
"colorTemperatureRange": null,
"dimLevelRange": null,
"onOffMode": "/on_off/"
},
"id": "18951651"
},
{
"customData": {
"colorTemperatureRange": {
"max": 600,
"min": 0
},
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "20134799"
},
{
"customData": {
"colorTemperatureRange": null,
"dimLevelRange": null,
"onOffMode": "/on_off/"
},
"id": "28426103"
},
{
"customData": {
"colorTemperatureRange": {
"max": 600,
"min": 0
},
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "24175054"
},
{
"customData": {
"colorTemperatureRange": null,
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "31877951"
},
{
"customData": {
"colorTemperatureRange": {
"max": 600,
"min": 0
},
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "31880526"
},
{
"customData": {
"colorTemperatureRange": null,
"dimLevelRange": null,
"onOffMode": "/on_off/"
},
"id": "23742906"
},
{
"customData": {
"colorTemperatureRange": null,
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "23190599"
},
{
"customData": {
"colorTemperatureRange": {
"max": 600,
"min": 0
},
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "27706708"
},
{
"customData": {
"colorTemperatureRange": {
"max": 600,
"min": 0
},
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "31750691"
},
{
"customData": {
"colorTemperatureRange": {
"max": 600,
"min": 0
},
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "18848065"
},
{
"customData": {
"colorTemperatureRange": {
"max": 600,
"min": 0
},
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "19152838"
},
{
"customData": {
"colorTemperatureRange": {
"max": 600,
"min": 0
},
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "19530298"
},
{
"customData": {
"colorTemperatureRange": {
"max": 600,
"min": 0
},
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "25920089"
},
{
"customData": {
"colorTemperatureRange": null,
"dimLevelRange": null,
"onOffMode": "/on_off/"
},
"id": "29823155"
},
{
"customData": {
"colorTemperatureRange": null,
"dimLevelRange": {
"max": 15,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "23647259"
},
{
"customData": {
"colorTemperatureRange": {
"max": 600,
"min": 0
},
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "26164657"
},
{
"customData": {
"colorTemperatureRange": {
"max": 600,
"min": 0
},
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "20730915"
},
{
"customData": {
"colorTemperatureRange": null,
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "27374037"
},
{
"customData": {
"colorTemperatureRange": {
"max": 600,
"min": 0
},
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "33430648"
},
{
"customData": {
"colorTemperatureRange": null,
"dimLevelRange": {
"max": 15,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "24978508"
},
{
"customData": {
"colorTemperatureRange": null,
"dimLevelRange": null,
"onOffMode": "/on_off/"
},
"id": "26597087"
},
{
"customData": {
"colorTemperatureRange": {
"max": 600,
"min": 0
},
"dimLevelRange": {
"max": 255,
"min": 0
},
"onOffMode": "/on_off/"
},
"id": "32442642"
},
{
"customData": {
"colorTemperatureRange": null,
"dimLevelRange": null,
"onOffMode": "/on_off/"
},
"id": "32558185"
}
],
"execution": [
{
"command": "action.devices.commands.OnOff",
"params": {
"on": true
}
}
]
}
]
}
}
],
"requestId": "11563706689114380169"
}
__RESPONSE______________________________________________________
[ UTC 14:40:31 12/1/2018 ] {
"requestId": "11563706689114380169",
"payload": {
"commands": [
{
"states": {
"on": true,
"online": true
},
"ids": [
"26782020",
"18951651",
"20134799",
"28426103",
"24175054",
"31877951",
"31880526",
"23742906",
"23190599",
"27706708",
"31750691",
"18848065",
"19152838",
"19530298",
"25920089",
"29823155",
"23647259",
"26164657",
"20730915",
"27374037",
"33430648",
"24978508",
"26597087",
"32442642",
"32558185"
],
"status": "SUCCESS"
}
]
}
}
(Apologies if the JSON formatting is a bit off)
The user claims not to have spoken any directives after turning off the one room. Beyond determining in the logs that an out-of-the-ordinary directive did get processed by our server, we have no idea what may caused this.
Has anyone else experienced a directive out of nowhere like this?
Thanks for reading.

Related

How to add json data in ConfigMap creation in ArgoCD

I'm trying to create a ConfigMap with ArgoCD.
I've created a volumes.yaml file as such
---
apiVersion: v1
kind: ConfigMap
metadata:
name: persistent-volumes-argo
labels:
grafana_dashboard: "1"
project: "foo"
data:
kubernetes.json: |
{{ .Files.Get "dashboards/persistent-volumes.json" | indent 4 }}
But ArgoCD doesn't seem to be able to read the data, the way a standard Helm deployment would.
I've tried adding the data directly into the ConfigMap as such
(Data omitted for brevity)
---
apiVersion: v1
kind: ConfigMap
metadata:
name: persistent-volumes-argo
labels:
grafana_dashboard: "1"
project: "foo"
data:
kubernetes.json: |
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"limit": 100,
"name": "Annotations & Alerts",
"showIn": 0,
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": 13646,
"graphTooltip": 0,
"iteration": 1659421503107,
"links": [],
"panels": [
{
"collapsed": false,
"datasource": null,
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 0
},
"id": 26,
"panels": [],
"title": "Alerts",
"type": "row"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"noValue": "--",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "semi-dark-red",
"value": null
},
{
"color": "light-green",
"value": -0.0001
},
{
"color": "semi-dark-red",
"value": 0.0001
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 8,
"x": 0,
"y": 1
},
"id": 21,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": false
},
"text": {},
"textMode": "auto"
},
"pluginVersion": "8.0.3",
"targets": [
{
"expr": "count (max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes{namespace=~\"${k8s_namespace}\"} ) and (max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes{namespace=~\"${k8s_namespace}\"} )) / (max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_capacity_bytes{namespace=~\"${k8s_namespace}\"} )) >= (${warning_threshold} / 100)) or vector (0)",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "PVCs Above Warning Threshold",
"type": "stat"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"decimals": 0,
"mappings": [],
"noValue": "--",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "semi-dark-red",
"value": null
},
{
"color": "light-green",
"value": -0.0001
},
{
"color": "semi-dark-red",
"value": 0.0001
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 8,
"x": 8,
"y": 1
},
"id": 24,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": false
},
"text": {},
"textMode": "auto"
},
"pluginVersion": "8.0.3",
"targets": [
{
"expr": "count((kube_persistentvolumeclaim_status_phase{namespace=~\"${k8s_namespace}\",phase=\"Pending\"}==1)) or vector(0)",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "PVCs in Pending State",
"transformations": [
{
"id": "organize",
"options": {}
}
],
"type": "stat"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"decimals": 0,
"mappings": [],
"noValue": "--",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "semi-dark-red",
"value": null
},
{
"color": "light-green",
"value": -0.0001
},
{
"color": "semi-dark-red",
"value": 0.0001
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 8,
"x": 16,
"y": 1
},
"id": 23,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": false
},
"text": {},
"textMode": "auto"
},
"pluginVersion": "8.0.3",
"targets": [
{
"expr": "count((kube_persistentvolumeclaim_status_phase{namespace=~\"${k8s_namespace}\",phase=\"Lost\"}==1)) or vector(0)",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "PVCs in Lost State",
"transformations": [
{
"id": "organize",
"options": {}
}
],
"type": "stat"
},
{
"collapsed": false,
"datasource": null,
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 5
},
"id": 17,
"panels": [],
"title": "Usage statistics",
"type": "row"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": null,
"displayMode": "auto",
"filterable": false
},
"mappings": [],
"noValue": "--",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "light-green",
"value": null
}
]
},
"unit": "none"
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Used (%)"
},
"properties": [
{
"id": "custom.displayMode",
"value": "gradient-gauge"
},
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{
"color": "light-green",
"value": null
},
{
"color": "semi-dark-yellow",
"value": 70
},
{
"color": "dark-red",
"value": 80
}
]
}
},
{
"id": "decimals",
"value": 1
}
]
},
{
"matcher": {
"id": "byName",
"options": "Status"
},
"properties": [
{
"id": "custom.displayMode",
"value": "color-background"
},
{
"id": "mappings",
"value": [
{
"options": {
"0": {
"text": "Bound"
},
"1": {
"text": "Pending"
},
"2": {
"text": "Lost"
}
},
"type": "value"
}
]
},
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{
"color": "light-green",
"value": null
},
{
"color": "light-green",
"value": 0
},
{
"color": "semi-dark-orange",
"value": 1
},
{
"color": "semi-dark-red",
"value": 2
}
]
}
},
{
"id": "noValue",
"value": "--"
},
{
"id": "custom.align",
"value": "center"
}
]
},
{
"matcher": {
"id": "byName",
"options": "Namespace"
},
"properties": [
{
"id": "custom.width",
"value": 120
}
]
},
{
"matcher": {
"id": "byName",
"options": "Status"
},
"properties": [
{
"id": "custom.width",
"value": 80
}
]
},
{
"matcher": {
"id": "byName",
"options": "Capacity (GiB)"
},
"properties": [
{
"id": "custom.width",
"value": 120
}
]
},
{
"matcher": {
"id": "byName",
"options": "Used (GiB)"
},
"properties": [
{
"id": "custom.width",
"value": 120
}
]
},
{
"matcher": {
"id": "byName",
"options": "Available (GiB)"
},
"properties": [
{
"id": "custom.width",
"value": 120
}
]
},
{
"matcher": {
"id": "byName",
"options": "StorageClass"
},
"properties": [
{
"id": "custom.width",
"value": 150
}
]
},
{
"matcher": {
"id": "byName",
"options": "PersistentVolumeClaim"
},
"properties": [
{
"id": "custom.width",
"value": 370
}
]
}
]
},
"gridPos": {
"h": 12,
"w": 24,
"x": 0,
"y": 6
},
"id": 29,
"interval": "",
"options": {
"frameIndex": 2,
"showHeader": true,
"sortBy": [
{
"desc": false,
"displayName": "PersistentVolumeClaim"
}
]
},
"pluginVersion": "8.0.3",
"targets": [
{
"expr": " sum by (persistentvolumeclaim,namespace,storageclass,volumename) (kube_persistentvolumeclaim_info{namespace=~\"${k8s_namespace}\"})",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "A"
},
{
"expr": "sum by (persistentvolumeclaim) (kubelet_volume_stats_capacity_bytes{namespace=~\"${k8s_namespace}\"}/1024/1024/1024)",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "B"
},
{
"expr": "sum by (persistentvolumeclaim) (kubelet_volume_stats_used_bytes{namespace=~\"${k8s_namespace}\"}/1024/1024/1024)",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "C"
},
{
"expr": "sum by (persistentvolumeclaim) (kubelet_volume_stats_available_bytes{namespace=~\"${k8s_namespace}\"}/1024/1024/1024)",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "D"
},
{
"expr": "sum(kube_persistentvolumeclaim_status_phase{namespace=~\"${k8s_namespace}\",phase=~\"(Pending|Lost)\"}) by (persistentvolumeclaim) + sum(kube_persistentvolumeclaim_status_phase{namespace=~\"${k8s_namespace}\",phase=~\"(Lost)\"}) by (persistentvolumeclaim)",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "E"
},
{
"expr": "sum by (persistentvolumeclaim) (kubelet_volume_stats_used_bytes{namespace=~\"${k8s_namespace}\"}/kubelet_volume_stats_capacity_bytes{namespace=~\"${k8s_namespace}\"} * 100)",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "F"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Persistent Volume Claim",
"transformations": [
{
"id": "seriesToColumns",
"options": {
"byField": "persistentvolumeclaim"
}
},
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true,
"Time 1": true,
"Time 2": true,
"Time 3": true,
"Time 4": true,
"Time 5": true,
"Time 6": true,
"Value #A": true
},
"indexByName": {},
"renameByName": {
"Time 1": "",
"Time 2": "",
"Time 3": "",
"Time 4": "",
"Time 5": "",
"Time 6": "",
"Value #A": "",
"Value #B": "Capacity (GiB)",
"Value #C": "Used (GiB)",
"Value #D": "Available (GiB)",
"Value #E": "Status",
"Value #F": "Used (%)",
"namespace": "Namespace",
"persistentvolumeclaim": "PersistentVolumeClaim",
"storageclass": "StorageClass",
"volumename": "PhysicalVolume"
}
}
}
],
"type": "table"
},
{
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"custom": {
"align": null,
"displayMode": "auto",
"filterable": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 24,
"x": 0,
"y": 18
},
"id": 7,
"options": {
"showHeader": true,
"sortBy": [
{
"desc": true,
"displayName": "Status"
}
]
},
"pluginVersion": "8.0.3",
"targets": [
{
"expr": "kube_storageclass_info",
"format": "table",
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Storage Class",
"transformations": [
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true,
"Value": true,
"__name__": true,
"app_kubernetes_io_instance": true,
"app_kubernetes_io_name": true,
"instance": true,
"job": true,
"kubernetes_namespace": true,
"kubernetes_pod_name": true,
"pod_template_hash": true
},
"indexByName": {
"Time": 1,
"Value": 13,
"__name__": 2,
"app_kubernetes_io_instance": 3,
"app_kubernetes_io_name": 4,
"instance": 5,
"job": 6,
"kubernetes_namespace": 7,
"kubernetes_pod_name": 8,
"pod_template_hash": 9,
"provisioner": 10,
"reclaimPolicy": 11,
"storageclass": 0,
"volumeBindingMode": 12
},
"renameByName": {
"provisioner": "Provisioner",
"reclaimPolicy": "ReclaimPolicy",
"storageclass": "StorageClass",
"volumeBindingMode": "VolumeBindingMode"
}
}
},
{
"id": "groupBy",
"options": {
"fields": {
"Provisioner": {
"aggregations": [],
"operation": "groupby"
},
"ReclaimPolicy": {
"aggregations": [],
"operation": "groupby"
},
"StorageClass": {
"aggregations": [],
"operation": "groupby"
},
"VolumeBindingMode": {
"aggregations": [],
"operation": "groupby"
}
}
}
}
],
"type": "table"
},
{
"collapsed": false,
"datasource": null,
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 23
},
"id": 15,
"panels": [],
"title": "Graphical usage data ",
"type": "row"
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "$datasource",
"fill": 0,
"fillGradient": 0,
"gridPos": {
"h": 12,
"w": 24,
"x": 0,
"y": 24
},
"hiddenSeries": false,
"id": 9,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": true,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "8.0.3",
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "(max by (persistentvolumeclaim,namespace) (kubelet_volume_stats_used_bytes{namespace=~\"${k8s_namespace}\"}))",
"interval": "",
"legendFormat": "{{namespace}} ({{persistentvolumeclaim}})",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "All Running PVCs Used Bytes",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "bytes",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "Date & time",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"collapsed": true,
"datasource": null,
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 36
},
"id": 19,
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 0,
"fillGradient": 0,
"gridPos": {
"h": 7,
"w": 24,
"x": 0,
"y": 41
},
"hiddenSeries": false,
"id": 11,
"legend": {
"alignAsTable": true,
"avg": true,
"current": false,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.1",
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "rate(kubelet_volume_stats_used_bytes{namespace=~\"${k8s_namespace}\"}[1h])",
"instant": false,
"interval": "",
"legendFormat": "{{namespace}} ({{persistentvolumeclaim}})",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Hourly Volume Usage Rate",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "binBps",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "Date & time",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 0,
"fillGradient": 0,
"gridPos": {
"h": 7,
"w": 24,
"x": 0,
"y": 48
},
"hiddenSeries": false,
"id": 12,
"legend": {
"alignAsTable": true,
"avg": true,
"current": false,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.2.1",
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "rate(kubelet_volume_stats_used_bytes{namespace=~\"${k8s_namespace}\"}[1d])",
"interval": "",
"legendFormat": "{{namespace}} ({{persistentvolumeclaim}})",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Daily Volume Usage Rate",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "binBps",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "Date & time",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "$datasource",
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 0,
"fillGradient": 0,
"gridPos": {
"h": 7,
"w": 24,
"x": 0,
"y": 55
},
"hiddenSeries": false,
"id": 13,
"legend": {
"alignAsTable": true,
"avg": true,
"current": false,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"alertThreshold": true
}
}
But this errors with rpc error: code = FailedPrecondition desc = Failed to unmarshal "volumes.yaml": <nil>
Is there a way to pass in json data when creating a ConfigMap with ArgoCD, either as a template or by dumping the data in the file?
To create configmap with argocd and helm
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "helm-chart.fullname" . }}-configmap
data:
config.json : |
{{ toJson .Values.configmap | indent 4 }}
and the value file should be like this, which is our JSON but converted to YAML
configmap:
json:
- rigid
- better for data interchange
yaml:
- slim and flexible
- better for configuration
object:
key: value
array:
- null_value:
- boolean: true
- integer: 1
- alias: &example aliases are like variables
- alias: *example
paragraph: >
Blank lines denote
paragraph breaks
content: |-
Or we
can auto
convert line breaks
to save space
alias: &foo
bar: baz
alias_reuse: *foo
json2yaml
A complete demo app can be found here
A very quick way to create app with the above configmap and demo app
argocd app create demo-app --repo https://github.com/Adiii717/argocd-demo-app.git --path helm-chart --dest-namespace default --dest-server https://kubernetes.default.svc --helm-set replicaCount=2
Make sure you also set
export ARGOCD_AUTH_TOKEN="tokeh
export ARGOCD_OPTS="--grpc-web"
export ARGOCD_SERVER="argocd.example.com"
added section for the configmap

MongoDB Aggregation Pipeline help (Convert MySQL to Mongo)

I know these have been asked a bunch and I am brand new to MongoDB which means I am struggling. I am using compass and trying to figure out this aggregation pipeline. In short, I need to get the average time difference between the max and min timestamp grouped by id.
The expected result would just be: avg_time: 234.00 or such.
The equivalent MySQL query looks like this:
select SEC_TO_TIME(AVG(TIME_TO_SEC(TIMEDIFF(a.maxDate,a.minDate)))) FROM (select id, min(timestamp) as minDate, max(timestamp) as maxDate from counterHistory group by id) as a
Here is what the dataset looks like:
[{
"_id": {
"$oid": "617dce992743dd52bed811a6"
},
"dateStart": {
"$date": "2021-10-30T23:00:41.056Z"
},
"dateEnd": {
"$date": "2021-10-30T23:00:52.404Z"
},
"areas": {
"c2acc5cc-9a7a-4406-8d91-79cb7f7ded70": {
"color": "yellow",
"type": "rightleft_bottomtop",
"location": {
"point1": {
"x": 1397,
"y": 702
},
"point2": {
"x": 1808,
"y": 645
},
"refResolution": {
"w": 1920,
"h": 969
}
},
"computed": {
"a": 0.15457277801631616,
"b": -332.7843438566361,
"lineBearings": [
81.21317228796154,
261.2131722879615
],
"point1": {
"x": 465.6666666666667,
"y": -260.80495356037153
},
"point2": {
"x": 602.6666666666666,
"y": -239.62848297213623
}
},
"name": "Right line start"
},
"56885eaf-9808-4b5e-b193-06b20e10c39d": {
"color": "turquoise",
"type": "rightleft_bottomtop",
"location": {
"point1": {
"x": 770,
"y": 411
},
"point2": {
"x": 1085,
"y": 360
},
"refResolution": {
"w": 1920,
"h": 969
}
},
"computed": {
"a": 0.18045112781954886,
"b": -199.0092879256966,
"lineBearings": [
79.77099171264048,
259.77099171264047
],
"point1": {
"x": 256.6666666666667,
"y": -152.6934984520124
},
"point2": {
"x": 361.6666666666667,
"y": -133.74613003095976
}
},
"name": "right lane end"
}
},
"videoResolution": {
"w": 640,
"h": 360
},
"filename": "demo.mp4",
"counterSummary": {
"56885eaf-9808-4b5e-b193-06b20e10c39d": {
"_total": 8,
"car": 8
},
"c2acc5cc-9a7a-4406-8d91-79cb7f7ded70": {
"_total": 8,
"car": 7,
"truck": 1
}
},
"trackerSummary": {
"totalItemsTracked": 64
},
"counterHistory": [
{
"frameId": 29,
"timestamp": {
"$date": "2021-10-30T23:00:42.694Z"
},
"area": "c2acc5cc-9a7a-4406-8d91-79cb7f7ded70",
"name": "car",
"id": 408,
"bearing": 291.8014094863518,
"countingDirection": "rightleft_bottomtop",
"angleWithCountingLine": 30.588237198390278
},
{
"frameId": 43,
"timestamp": {
"$date": "2021-10-30T23:00:43.619Z"
},
"area": "c2acc5cc-9a7a-4406-8d91-79cb7f7ded70",
"name": "truck",
"id": 457,
"bearing": 293.1985905136482,
"countingDirection": "rightleft_bottomtop",
"angleWithCountingLine": 31.985418225686644
},
{
"frameId": 50,
"timestamp": {
"$date": "2021-10-30T23:00:44.063Z"
},
"area": "56885eaf-9808-4b5e-b193-06b20e10c39d",
"name": "car",
"id": 421,
"bearing": 303.69006752597977,
"countingDirection": "rightleft_bottomtop",
"angleWithCountingLine": 43.919075813339305
},
{
"frameId": 63,
"timestamp": {
"$date": "2021-10-30T23:00:44.927Z"
},
"area": "c2acc5cc-9a7a-4406-8d91-79cb7f7ded70",
"name": "car",
"id": 458,
"bearing": 293.6293777306568,
"countingDirection": "rightleft_bottomtop",
"angleWithCountingLine": 32.41620544269528
},
{
"frameId": 65,
"timestamp": {
"$date": "2021-10-30T23:00:45.054Z"
},
"area": "56885eaf-9808-4b5e-b193-06b20e10c39d",
"name": "car",
"id": 464,
"bearing": 284.03624346792645,
"countingDirection": "rightleft_bottomtop",
"angleWithCountingLine": 24.265251755286005
},
{
"frameId": 78,
"timestamp": {
"$date": "2021-10-30T23:00:45.888Z"
},
"area": "c2acc5cc-9a7a-4406-8d91-79cb7f7ded70",
"name": "car",
"id": 469,
"bearing": 303.69006752597977,
"countingDirection": "rightleft_bottomtop",
"angleWithCountingLine": 42.47689523801825
},
{
"frameId": 86,
"timestamp": {
"$date": "2021-10-30T23:00:46.415Z"
},
"area": "56885eaf-9808-4b5e-b193-06b20e10c39d",
"name": "car",
"id": 427,
"bearing": 354.28940686250036,
"countingDirection": "rightleft_bottomtop",
"angleWithCountingLine": 85.48158485014012
},
{
"frameId": 122,
"timestamp": {
"$date": "2021-10-30T23:00:48.757Z"
},
"area": "c2acc5cc-9a7a-4406-8d91-79cb7f7ded70",
"name": "car",
"id": 479,
"bearing": 296.565051177078,
"countingDirection": "rightleft_bottomtop",
"angleWithCountingLine": 35.35187888911645
},
{
"frameId": 125,
"timestamp": {
"$date": "2021-10-30T23:00:48.946Z"
},
"area": "56885eaf-9808-4b5e-b193-06b20e10c39d",
"name": "car",
"id": 408,
"bearing": 323.13010235415595,
"countingDirection": "rightleft_bottomtop",
"angleWithCountingLine": 63.359110641515514
},
{
"frameId": 143,
"timestamp": {
"$date": "2021-10-30T23:00:50.143Z"
},
"area": "56885eaf-9808-4b5e-b193-06b20e10c39d",
"name": "car",
"id": 473,
"bearing": 284.03624346792645,
"countingDirection": "rightleft_bottomtop",
"angleWithCountingLine": 24.265251755286005
},
{
"frameId": 152,
"timestamp": {
"$date": "2021-10-30T23:00:50.716Z"
},
"area": "c2acc5cc-9a7a-4406-8d91-79cb7f7ded70",
"name": "car",
"id": 438,
"bearing": 296.565051177078,
"countingDirection": "rightleft_bottomtop",
"angleWithCountingLine": 35.35187888911645
},
{
"frameId": 160,
"timestamp": {
"$date": "2021-10-30T23:00:51.242Z"
},
"area": "56885eaf-9808-4b5e-b193-06b20e10c39d",
"name": "car",
"id": 455,
"bearing": 45,
"countingDirection": "rightleft_bottomtop",
"angleWithCountingLine": 34.77099171264047
},
{
"frameId": 174,
"timestamp": {
"$date": "2021-10-30T23:00:52.149Z"
},
"area": "c2acc5cc-9a7a-4406-8d91-79cb7f7ded70",
"name": "car",
"id": 492,
"bearing": 327.2647737278924,
"countingDirection": "rightleft_bottomtop",
"angleWithCountingLine": 66.05160143993088
},
{
"frameId": 175,
"timestamp": {
"$date": "2021-10-30T23:00:52.212Z"
},
"area": "56885eaf-9808-4b5e-b193-06b20e10c39d",
"name": "car",
"id": 469,
"bearing": 281.30993247402023,
"countingDirection": "rightleft_bottomtop",
"angleWithCountingLine": 21.538940761379738
}
]
}]
Here is my atrocious pipeline that at least gives me the result that I am looking for. So I guess, how do you optimize this?
[{$match: {
_id:ObjectId('617dce992743dd52bed811a6')
}}, {$unwind: {
path: "$counterHistory",
}}, {$group: {
_id: "$counterHistory.id",
maxDate:{$max:"$counterHistory.timestamp"},
minDate:{$min:"$counterHistory.timestamp"}
}}, {$project: {
_id:1,
minDate:1,
maxDate:1,
noMatchingDates:{$ne:["$maxDate","$minDate"]}
}}, {$match: {
noMatchingDates:true
}}, {$group: {
_id: null,
"avg_time": {
"$avg": {
"$subtract": [
{ "$ifNull": [ "$maxDate", 0 ] },
{ "$ifNull": [ "$minDate", 0 ] }
]
}
}
}}, {$project: {
avg_time:1,
hours: { $divide: [ "$avg_time", 3600000 ] },
minutes: { $divide: [ "$avg_time", 60000 ] },
seconds: { $divide: [ "$avg_time", 1000 ] }
}}]
So as I put up above and confirmed by YuTing, this pipeline works:
[{$match: {
_id:ObjectId('617dce992743dd52bed811a6')
}}, {$unwind: {
path: "$counterHistory",
}}, {$group: {
_id: "$counterHistory.id",
maxDate:{$max:"$counterHistory.timestamp"},
minDate:{$min:"$counterHistory.timestamp"}
}}, {$project: {
_id:1,
minDate:1,
maxDate:1,
noMatchingDates:{$ne:["$maxDate","$minDate"]}
}}, {$match: {
noMatchingDates:true
}}, {$group: {
_id: null,
"avg_time": {
"$avg": {
"$subtract": [
{ "$ifNull": [ "$maxDate", 0 ] },
{ "$ifNull": [ "$minDate", 0 ] }
]
}
}
}}, {$project: {
avg_time:1,
hours: { $divide: [ "$avg_time", 3600000 ] },
minutes: { $divide: [ "$avg_time", 60000 ] },
seconds: { $divide: [ "$avg_time", 1000 ] }
}}]

Post grafana dashboard to particular folder

I am trying to use the grafana API to post dashboards to a specific folder. Using the following command, I can see the folder ID's for all folders in my grafana:
curl -X GET http://<username>:<password>#localhost:3000/api/folders?limit=200
[{"id":9,"uid":"6m0M3AZZk","title":"Apps"},{"id":38,"uid":"jEJ5aSVZz","title":"Cluster_Health"},{"id":31,"uid":"vsmJ2dGZz","title":"CPU by App"},{"id":51,"uid":"Fx9ajQXWz","title":"Data Pipeline"},{"id":6,"uid":"dYFMMhZWz","title":"home"},{"id":19,"uid":"qDwG6yWZz","title":"Node_Health"},{"id":18,"uid":"37pWeyWZk","title":"Pending_Data"},{"id":44,"uid":"nreWbxfWz","title":"Prod"},{"id":13,"uid":"PYzEBYZWk","title":"Services"},{"id":27,"uid":"byVe4IMWk","title":"API"}]
Now, I would like to post a dashboard to my Services folder (id 13). However, when I make my request, this dashboard is always going to the General folder. I am using a python script to make my request:
def post_dashboard(filepath):
with open(filepath, "r") as fin:
data = json.loads(fin.read())
data = json.dumps(data)
response = requests.post("http://localhost:3000/api/dashboards/db", headers=headers_raw, data=data)
print(response.json())
print(response.status_code)
My JSON file looks like this:
{"dashboard": {
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": null,
"iteration": 1593098750052,
"links": [],
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Prometheus-1",
"description": "The amount of CPU taken up by redis from top command",
"fill": 0,
"gridPos": {
"h": 8,
"w": 24,
"x": 0,
"y": 0
},
"id": 10,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "app_cpu{node_type=\"process\", cluster_id=~\"$cluster\", app_name=~\".*redisserver.*\"}",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{ host_name }}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "CPU Used",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Prometheus-1",
"description": "The current amount of memory redis is consuming",
"fill": 0,
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 8
},
"id": 2,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "redis_mem_used{cluster_id=~\"$cluster\"}",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{ node }}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Redis Memory Used",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "decbytes",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Prometheus-1",
"description": "The maximum amount of memory that redis has used",
"fill": 0,
"gridPos": {
"h": 9,
"w": 12,
"x": 12,
"y": 8
},
"id": 4,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "redis_mem_peak{cluster_id=~\"$cluster\"}",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{ node }}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Redis Peak Memory",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "decbytes",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Prometheus-1",
"description": "The amount of memory used by the LUA engine inside of redis",
"fill": 0,
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 17
},
"id": 6,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "redis_mem_lua{cluster_id=~\"$cluster\"}",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{ node }}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "LUA Mem Used",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "decbytes",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "Prometheus-1",
"description": "The amount of memory used as observed by top",
"fill": 0,
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 17
},
"id": 8,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "redis_mem_rss{cluster_id=~\"$cluster\"}",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "{{ node }}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "RSS Mem Used",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "decbytes",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
}
],
"schemaVersion": 18,
"style": "dark",
"tags": [],
"templating": {
"list": [
{
"allValue": null,
"current": {},
"datasource": "Prometheus-1",
"definition": "label_values(redis_mem_used, cluster_id)",
"hide": 0,
"includeAll": true,
"label": null,
"multi": true,
"name": "cluster",
"options": [],
"query": "label_values(redis_mem_used, cluster_id)",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "",
"title": "Redis",
"uid": "rfdsk32",
"folder": "Services",
"folderTitle": "Services",
"folderId": 13,
"overwrite": true
}
}
My grafana version is 6.2.0. I have used several references that say that folderId should be the controlling keyword for which folder a dashboard goes to.
https://grafana.com/docs/grafana/latest/http_api/dashboard/#create-update-dashboard
You have used wrong payload structure:
{
"dashboard": {
...
"folderId": 13,
"overwrite": true
}
}
Correct structure is:
{
"dashboard": {
...
},
"folderId": 13,
"overwrite": true
}

How to update a part of an array sub document in MongoDB

I have this document in my mongodb collection:
{
"_id": "YLRM9Wi7f6tp6qNbS",
"sessionId": "hLDkkJKR4Muik6tbe",
"userId": "ZYoG4cH8HcCDPMDGr",
"shopId": "J8Bhq3uTtdgwZx3rz",
"workflow": {
"status": "",
"workflow": ["String"]
},
"billing": [Object],
"discount": 0,
"tax": 0,
"items": [
{
"_id": "JwR233jD2c4HKeYKq",
"shopId": "J8Bhq3uTtdgwZx3rz",
"productId": "BCTMZ6HTxFSppJESk",
"quantity": 1,
"product": {
"_id": "BCTMZ6HTxFSppJESk",
"title": "Product",
"shopId": "J8Bhq3uTtdgwZx3rz",
"ancestors": [],
"createdAt": "2018-01-12T10:22:18.853Z",
"description": "",
"handle": "product",
"hashtags": [
"rpjCvTBGjhBi2xdro",
"cseCBSSrJ3t8HQSNP"
],
"price": {
"range": "12.99 - 19.99",
"min": 12.99,
"max": 19.99
},
"isVisible": true,
"isLowQuantity": false,
"isSoldOut": false,
"isBackorder": false,
"metafields": [
{
"key": "Material",
"value": "Cotton"
},
{
"key": "Quality",
"value": "Excellent"
}
],
"pageTitle": "",
"type": "simple",
"updatedAt": "2018-01-12T10:22:18.854Z",
"vendor": "Vendor_Name",
"originCountry": "country",
"requiresShipping": true,
"isDeleted": false,
"template": "productDetailSimple",
"workflow": {
"status": "new"
}
},
"variants": {},
"title": "Product",
"type": "simple",
"parcel": {
"weight": 25,
"height": 3,
"width": 10,
"length": 10
},
"shippingMethod": {
"shopId": "J8Bhq3uTtdgwZx3rz",
"shipmentQuotes": [Object],
"shipmentQuotesQueryStatus": {
"requestStatus": "success",
"numOfShippingMethodsFound": 11
},
"_id": "s3EJXrLsZe73RbLiD",
"address": {},
"shipmentMethod": {},
"paymentId": "nyybR5BNvDDrJrtwe",
"items": [
{
"_id": "JwR233jD2c4HKeYKq",
"productId": "BCTMZ6HTxFSppJESk",
"shopId": "J8Bhq3uTtdgwZx3rz",
"variantId": "CJoRBm9vRrorc9mxZ"
}
],
"workflow": {
"status": "new",
"workflow": ["String"]
}
},
"workflow": {
"status": "new",
"workflow": ["String"]
}
}
],
"shipping": [Object],
"email": "johndoe#mail.com",
"cartId": "L6sSGv4NR9rpbDbsd",
"createdAt": "2018-01-12T10:22:18.850Z"
}
The field items is an array of objects, I would like to update just a part of the object specifically the workflow field without touching other part of the objects in items array.
I was able to do this using a loop, but it caused some tests to fail. Is there a better of doing this with using a loop?
Thank you.
You can try findAndModify method.
Traverse to the workflow key ad try to set the value.
Hope this would help.

How long time should it take for service fabric to go from deploying->autoscale->ready?

From the output below its seen that the cluster is still in "deploying" mode, waiting for the "autoscale"->"ready" states to kick in. But looking at the nodes, they been running with nodestatus = 1 for 20min.
Is it possible to get some insights into what triggers that step from deploying to autoscale->ready?
Is time correlated with size of node machines?
C:\Users\pks>armclient get /subscriptions/8393a037-5d39-462d-a583-09915b4493df/resourcegroups/ci-sf-tests4/providers/Microsoft.ServiceFabric/clusters/citestcluster4?api-version=2016-03-01
{
"type": "Microsoft.ServiceFabric/clusters",
"location": "West Europe",
"id": "/subscriptions/8393a037-5d39-462d-a583-09915b4493df/resourcegroups/ci-sf-tests4/providers/Microsoft.ServiceFabric/clusters/citestcluster4",
"name": "citestcluster4",
"tags": {
"hidden-resourceType": "Service Fabric",
"hidden-clusterName": "citestcluster4"
},
"etag": "W/\"636020077930324002\"",
"properties": {
"provisioningState": "Succeeded",
"clusterId": "909e26fe-3d44-4bf9-942d-dea6d37b0b2c",
"clusterCodeVersion": "5.1.150.9590",
"clusterState": "Deploying",
"managementEndpoint": "https://citestcluster4.westeurope.cloudapp.azure.com:19080",
"clusterEndpoint": "https://westeurope.servicefabric.azure.com/runtime/clusters/909e26fe-3d44-4bf9-942d-dea6d37b0b2c",
"certificate": {
"thumbprint": "4BE52A76D3E63B159F8475B56B40D29D20584FF5",
"x509StoreName": "My"
},
"clientCertificateThumbprints": [],
"clientCertificateCommonNames": [],
"fabricSettings": [
{
"name": "Security",
"parameters": [
{
"name": "ClusterProtectionLevel",
"value": "EncryptAndSign"
}
]
}
],
"diagnosticsStorageAccountConfig": {
"storageAccountName": "h7vokscadqdiy2",
"protectedAccountKeyName": "StorageAccountKey1",
"blobEndpoint": "https://h7vokscadqdiy2.blob.core.windows.net/",
"queueEndpoint": "https://h7vokscadqdiy2.queue.core.windows.net/",
"tableEndpoint": "https://h7vokscadqdiy2.table.core.windows.net/"
},
"vmImage": "Windows",
"reliabilityLevel": "Silver",
"nodeTypes": [
{
"name": "nt1vm",
"placementProperties": {
"isPrimary": "true",
"vmNodeTypeSize": "Standard_A0"
},
"capacities": {
"memory": "100"
},
"clientConnectionEndpointPort": 19000,
"httpGatewayEndpointPort": 19080,
"applicationPorts": {
"startPort": 20000,
"endPort": 30000
},
"ephemeralPorts": {
"startPort": 49152,
"endPort": 65534
},
"isPrimary": true,
"vmInstanceCount": 5,
"durabilityLevel": "Bronze"
}
]
}
}
C:\Users\pks>armclient get /subscriptions/8393a037-5d39-462d-a583-09915b4493df/resourcegroups/ci-sf-tests4/providers/Microsoft.ServiceFabric/clusters/citestcluster4/nodes?api-version=2016-03-01
{
"value": [
{
"id": "/subscriptions/8393a037-5d39-462d-a583-09915b4493df/resourcegroups/ci-sf-tests4/providers/Microsoft.ServiceFabric/clusters/citestcluster4/Nodes/_nt1vm_2",
"properties": {
"Name": "_nt1vm_2",
"IpAddressOrFQDN": "10.0.0.6",
"Type": "nt1vm",
"CodeVersion": "5.1.150.9590",
"ConfigVersion": "1",
"NodeStatus": 1,
"NodeUpTimeInSeconds": "1276",
"HealthState": 1,
"IsSeedNode": true,
"UpgradeDomain": "2",
"FaultDomain": "fd:/2",
"Id": {
"Id": "2153dcef983f79f6d056f74e724abf00"
},
"InstanceId": "131108866624879337",
"NodeDeactivationInfo": {
"NodeDeactivationIntent": 0,
"NodeDeactivationStatus": 0,
"NodeDeactivationTask": [],
"PendingSafetyChecks": []
}
}
},
{
"id": "/subscriptions/8393a037-5d39-462d-a583-09915b4493df/resourcegroups/ci-sf-tests4/providers/Microsoft.ServiceFabric/clusters/citestcluster4/Nodes/_nt1vm_0",
"properties": {
"Name": "_nt1vm_0",
"IpAddressOrFQDN": "10.0.0.4",
"Type": "nt1vm",
"CodeVersion": "5.1.150.9590",
"ConfigVersion": "1",
"NodeStatus": 1,
"NodeUpTimeInSeconds": "1275",
"HealthState": 1,
"IsSeedNode": true,
"UpgradeDomain": "0",
"FaultDomain": "fd:/0",
"Id": {
"Id": "310a2a579b75d9847ba5a43d6b365d7c"
},
"InstanceId": "131108866767599090",
"NodeDeactivationInfo": {
"NodeDeactivationIntent": 0,
"NodeDeactivationStatus": 0,
"NodeDeactivationTask": [],
"PendingSafetyChecks": []
}
}
},
{
"id": "/subscriptions/8393a037-5d39-462d-a583-09915b4493df/resourcegroups/ci-sf-tests4/providers/Microsoft.ServiceFabric/clusters/citestcluster4/Nodes/_nt1vm_3",
"properties": {
"Name": "_nt1vm_3",
"IpAddressOrFQDN": "10.0.0.7",
"Type": "nt1vm",
"CodeVersion": "5.1.150.9590",
"ConfigVersion": "1",
"NodeStatus": 1,
"NodeUpTimeInSeconds": "1275",
"HealthState": 1,
"IsSeedNode": true,
"UpgradeDomain": "3",
"FaultDomain": "fd:/3",
"Id": {
"Id": "899b5afa0a70e1af4a620eda67d0260f"
},
"InstanceId": "131108866347571432",
"NodeDeactivationInfo": {
"NodeDeactivationIntent": 0,
"NodeDeactivationStatus": 0,
"NodeDeactivationTask": [],
"PendingSafetyChecks": []
}
}
},
{
"id": "/subscriptions/8393a037-5d39-462d-a583-09915b4493df/resourcegroups/ci-sf-tests4/providers/Microsoft.ServiceFabric/clusters/citestcluster4/Nodes/_nt1vm_4",
"properties": {
"Name": "_nt1vm_4",
"IpAddressOrFQDN": "10.0.0.8",
"Type": "nt1vm",
"CodeVersion": "5.1.150.9590",
"ConfigVersion": "1",
"NodeStatus": 1,
"NodeUpTimeInSeconds": "1268",
"HealthState": 1,
"IsSeedNode": true,
"UpgradeDomain": "4",
"FaultDomain": "fd:/4",
"Id": {
"Id": "bde184b3d9f49b2af32e8037eb951483"
},
"InstanceId": "131108867572806882",
"NodeDeactivationInfo": {
"NodeDeactivationIntent": 0,
"NodeDeactivationStatus": 0,
"NodeDeactivationTask": [],
"PendingSafetyChecks": []
}
}
},
{
"id": "/subscriptions/8393a037-5d39-462d-a583-09915b4493df/resourcegroups/ci-sf-tests4/providers/Microsoft.ServiceFabric/clusters/citestcluster4/Nodes/_nt1vm_1",
"properties": {
"Name": "_nt1vm_1",
"IpAddressOrFQDN": "10.0.0.5",
"Type": "nt1vm",
"CodeVersion": "5.1.150.9590",
"ConfigVersion": "1",
"NodeStatus": 1,
"NodeUpTimeInSeconds": "976",
"HealthState": 1,
"IsSeedNode": true,
"UpgradeDomain": "1",
"FaultDomain": "fd:/1",
"Id": {
"Id": "de98611a5345b01b365ee8e6d67bfcad"
},
"InstanceId": "131108870541748899",
"NodeDeactivationInfo": {
"NodeDeactivationIntent": 0,
"NodeDeactivationStatus": 0,
"NodeDeactivationTask": [],
"PendingSafetyChecks": []
}
}
}
]
}
Is your cluster too small? Standard_A0 (which is what I think I read) is not that big and it could just be that it is taking a long time.