How to create widget in a single AWS Cloud Watch dashboard for a list of instances - terraform-provider-aws

Terraform (aws provider) beginner here. I am trying to create aws-cloudwatch widget that graphs CPU Utilization for 3 instances. However, I only get one graph generated for the last instance in the list instead three graphs on one widget! How can I fix this please or get this How can I get this code to create CPUUtilisation graph for three instances on the same widget? Thank you
variable "targets" {
default = ["i-086e06769b6c67665","i-0477b6f25ad155290","i-0e6320273511d17dc"]
}
resource "aws_cloudwatch_dashboard" "ec2" {
dashboard_name = "ec2-test-dashboard"
count = length(var.targets)
dashboard_body = <<EOF
{
"widgets": [
{
"type": "metric",
"x": 0,
"y": 0,
"width": 17,
"height": 8,
"properties": {
"metrics": [
["AWS/EC2","CPUUtilization","InstanceId","${(var.targets[count.index])}"]
],
"title": "EC2 dashboard: CPUUtilization",
"stat": "Average",
"period": 300,
"stacked": false,
"view": "timeSeries",
"region": "eu-west-1",
"annotations": {
"horizontal": [
{
"label": "critical range",
"value": 10
}
]
},
"legend": {
"position": "right"
}
}
}
]
}
EOF
}

Related

Vega-Lite: Add a layer to a multi view plot based on an if-condition

I'm trying to build a simple text only dashboard with Kibana based on responses like the one below
{
"_index": "jenkins-plasma4-2022.04.08-000001",
"_type": "_doc",
"_id": "nhKIQYABmFVLYNIVp4H3",
"_score": 0,
"_source": {
"branch": "trunk",
"status": "UNSTABLE",
"buildnumber": 5501,
"failedStages": ["System Test"],
"suspectedCommits": []
}
I'm using vconcat right now:
"vconcat": [
{
"mark": {"type": "text", "fontSize": 50},
"encoding": {
"text": {"field": "buildnumber", "type": "nominal",}
}
},
{
"mark": {"type": "text", "fontSize": 50},
"encoding": {
"text": {"field": "status", "type": "nominal",}
}
}
]
In some situations "suspectedCommits" will not be empty, in those cases I'd like to be able to add to a multi view visualization

Not able to filter out required property in Azure TSI Gen1 Get Events API response

I am using the below request body to fetch only the required property values.
"searchSpan": {
"from": {
"dateTime": "2021-11-20T00:00:00.000Z"
},
"to": {
"dateTime": "2021-11-20T23:00:00.000Z"
}
},
"predicateString": "[Params.Name] = 'power'",
"take": 100
}
}
The URL is like below:
https://12345678a-bcde-3e91-blah-2292933292aa.env.timeseries.azure.com/events?api-version=2016-12-12
Despite specifying the required property the response returns all properties as if it has not seen the predicate string. What might I be doing wrong?
{
"warnings": [],
"events": [
{
"schema": {
"rid": 0,
"$esn": "my-event-hub",
"properties": [
{
"name": "mytimestamp",
"type": "DateTime"
},
{
"name": "Params.Name",
"type": "String"
},
{
"name": "Params.Value",
"type": "Double"
}
]
},
"$ts": "2021-11-20T10:01:50Z",
"values": [
"2021-11-20T10:01:50Z",
"energy",
60
]
},
{
"schemaRid": 0,
"$ts": "2021-11-20T10:01:50Z",
"values": [
"2021-11-20T10:01:50Z",
"power",
10
]
},
{
"schemaRid": 0,
"$ts": "2021-11-20T10:01:50Z",
"values": [
"2021-11-20T10:01:50Z",
"strength",
200
]
},
]
}
Edit
I'm getting "Properties count error" in the TSI overview page. This might quite be the root cause but I don't know for sure
"For Time Series Insights environment ABC: You have used all 641/600 properties in your environment".

NGRX entity adapter - how to update/upsert many nested properties

I am trying to update many entities using adapter.updateMany().
I have Groups entity that looks like this (There are multiple groups with multiple children):
{
"id": 1,
"children": [
{
"id": 222,
"width": null,
"height": null,
...multipleOtherProperties
}
]
}
I am trying to update child width and height inside the group with:
const groups = [
{
"id": 0,
"children": [
{
"id": 222,
"groupId": 0,
"width": 400,
"height": 368.28125
}
]
}
]
But when I use:
on(GroupsActions.updateGroups, (state, { groups }) =>
adapter.updateMany(groups, state)
)
Nothing is happening and when I change updateMany to upsertMany
on(GroupsActions.updateGroups, (state, { groups }) =>
adapter.upsertMany(groups, state)
)
Children are replaced and I am losing all the properties which are not part of the update.
How to update the properties of children without removing all other properties?
Any help would be appreciated. Thank you

Create product variations with python woocommerce api

I am attempting to create a product with variations in WooCommerce but I am getting this error:
{u'message': u'No route was found matching the URL and request method', u'code': u'rest_no_route', u'data': {u'status': 404}}
when I run the create_variation function from the API.
I ran a GET on the attributes for the product I created and it found no attributes even though the printed response when I created the product had the attributes listed.
Here is my code to create the variable product:
data = {
"name": row[3],
"type": "variable",
"description": row[4],
"images": [
{
"src": row[15],
"position": 0
}
],
"in_stock": True,
"sku": row[2],
'attributes': [
{
'name': 'Size',
'variation': True,
'visible': True,
'options': sizeList,
},
{
'name': 'Color',
'variation': True,
'visible': True,
'options': colorList,
}
],
}
print(wcapiNew.post("products", data).json())
Here is my code to create the variations:
result = wcapi.get("products/sku/"+row[2]).json()
product_id = result['product']['id']
variationData = {
"regular_price": row[17],
"image": {
"src": row[13]
},
"sku": row[19],
"attributes": [
{
"name": "Color",
"option": row[6]
},
{
"name": "Size",
"option": row[10]
}
]
}
print(wcapiNew.post("products/"+str(product_id)+"/variations", variationData).json())
I've been tearing my hair out trying to figure out what I'm doing wrong but I'm clueless right now.
Any help is appreciated. Thanks.
This is my variations data, and it work.
data_1 = {
"regular_price": "9.00",
"sku": "premium-quality-101-red",
"attributes": [
{
"id": 1,
"option": "Red"
}]
}
I figure out that you need to use id, and update one variation at a time.

How to get the Bounding box values from a GeoJSON file?

I have of GeoJSON file. But problem is, I do not know the projection of this file. Now, I want to overlay on my base map(OSM). How should I do it? This GeoJSON file contains features around Stockholm area. How can i set the bounding box for this? I tried with couple of openlayers example from hosting sites. But, those do not work for me. I got one example which is very similar with what i want, from (http://dev.openlayers.org/releases/OpenLayers-2.11/examples/all-overlays.html). I checked the source code he used bounding box. But problem is, if I remove bounding box this example does not work(I tied with given data with this). I do not know, is there anything wrong with my json file? Bellow, I have given some sample data. Is the format OK? As I told, I tried with different way. Some time i read the json file just fine from script. But, It can not show the featured overlay ed map. Bellow, I gave sample code, that shows how I tried.
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { "FNODE_": 387603, "TNODE_": 387603, "LPOLY_": 0, "RPOLY_": 0, "LENGTH": 89.206900, "ROADS_SWER": 519006, "ROADS_SW_1": 519006, "REF": "", "TYPE": "residential", "ONEWAY": 8224, "BRIDGE": 8224, "MAXSPEED": 0, "LENGTH_M": 89.500000, "ID": 0, "dist_fnode": 13655.200000, "dist_tnode": 13655.200000 }, "geometry": { "type": "LineString", "coordinates": [ [ 676868.875000, 6569872.000000 ], [ 676882.437500, 6569861.000000 ], [ 676894.062500, 6569851.500000 ], [ 676894.500000, 6569844.500000 ], [ 676891.812500, 6569840.500000 ], [ 676887.312500, 6569841.000000 ], [ 676882.187500, 6569843.000000 ], [ 676875.250000, 6569850.000000 ], [ 676868.125000, 6569858.500000 ], [ 676866.500000, 6569867.000000 ], [ 676868.875000, 6569872.000000 ] ] } }
,
{ "type": "Feature", "properties": { "FNODE_": 387723, "TNODE_": 387724, "LPOLY_": 0, "RPOLY_": 0, "LENGTH": 9.581310, "ROADS_SWER": 519163, "ROADS_SW_1": 519163, "REF": "", "TYPE": "service", "ONEWAY": 8224, "BRIDGE": 8224, "MAXSPEED": 0, "LENGTH_M": 9.500000, "ID": 1, "dist_fnode": 13705.100000, "dist_tnode": 13695.600000 }, "geometry": { "type": "LineString", "coordinates": [ [ 677125.375000, 6569906.500000 ], [ 677133.437500, 6569911.500000 ] ] } }
,
..
..
]
}
Code Sample----
//OSM Layer-----------------------------------------------
var layer = new OpenLayers.Layer.OSM( "Simple OSM Map");
//GeoJSON Layer-------------------------------------------
var vector_format = new OpenLayers.Format.GeoJSON({});
var vector_protocol = new OpenLayers.Protocol.HTTP({
url: 'ml/roads.json',
format: vector_format
});
var vector_strategies = [new OpenLayers.Strategy.Fixed()];
var vector_layer = new OpenLayers.Layer.Vector('More Advanced Vector Layer',{
protocol: vector_protocol,
strategies: vector_strategies,
isBaseLayer: false
});
var options = {
layers: [layer, vector_layer]
};
var map = new OpenLayers.Map("map", options);
//Projection-----------------------------------------------
map.setCenter(
new OpenLayers.LonLat(18.068611, 59.329444).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
), 10
);
Thanks, in advance.
vector_layer.events.on({
loadend: function() {
map.zoomToExtent(vector_layer.getDataExtent());
}
});
I still think you should set your projection in the map constructor…

Resources