OpenStack Gnocchi - Equivalent of ceilometer /v2/meter/[meter]/statistics - openstack

I'm looking for the exact equivalent of the /meter/[meterName]/statistics endpoint of the ceilometer web api for Gnocchi, but I'm struggling finding the equivalent, it looks like there is no way to retrieve the same informations.
The ceilometer endpoint mentions that When a simple statistics request is invoked (using GET /v2/meters/<meter_name>/statistics), it will return the standard set of Statistics: avg, sum, min, max, and count. and provides an expressive API allowing to apply further filtering and advanced search options, like this:
GET /v2/meters/instance/statistics
q: [{"field": "user_id",
"op": "eq",
"value": "user-2"},
{"field": "source",
"op": "eq",
"value": "source-1"}]
groupby: ["project_id", "resource_id"]
which will produce an output like this:
[{"count": 4, "duration_start": "2013-09-18T19:08:33", "min": 1.0,
"max": 1.0, "duration_end": "2013-09-18T19:27:30", "period": 0,
"sum": 4.0, "period_end": "2013-09-18T19:27:30", "duration": 1137.0,
"period_start": "2013-09-18T19:08:33", "avg": 1.0,
"groupby": {"project_id": "c2334f175d8b4cb8b1db49d83cecde78",
"resource_id": "551f495f-7f49-4624-a34c-c422f2c5f90b"},
"unit": "image"},
{"count": 4, "duration_start": "2013-09-18T19:08:36", "min": 1.0,
"max": 1.0, "duration_end": "2013-09-18T19:27:30", "period": 0,
"sum": 4.0, "period_end": "2013-09-18T19:27:30", "duration": 1134.0,
"period_start": "2013-09-18T19:08:36", "avg": 1.0,
"groupby": {"project_id": "c2334f175d8b4cb8b1db49d83cecde78",
"resource_id": "7c1157ed-cf30-48af-a868-6c7c3ad7b531"},
"unit": "image"},
{"count": 4, "duration_start": "2013-09-18T19:08:34", "min": 1.0,
"max": 1.0, "duration_end": "2013-09-18T19:27:30", "period": 0,
"sum": 4.0, "period_end": "2013-09-18T19:27:30", "duration": 1136.0,
"period_start": "2013-09-18T19:08:34", "avg": 1.0,
"groupby": {"project_id": "c2334f175d8b4cb8b1db49d83cecde78",
"resource_id": "eaed9cf4-fc99-4115-93ae-4a5c37a1a7d7"},
"unit": "image"}]
(documentation about that can be found here).
In Gnocchi, instead (documentation about web apis can be found here) I didn't find any way to produce the same info, the closest I could match was using the dynamic aggregates api, although there does not seem any way to filter on the metadata: https://gnocchi.osci.io/rest.html#groupby
POST /v1/aggregates?start=2014-10-06T14:34&groupby=host&groupby=flavor_id HTTP/1.1
Content-Type: application/json
Content-Length: 149
{
"operations": "(* (aggregate mean (metric cpu.util mean)) 4)",
"resource_type": "instance",
"search": "server_group='my_autoscaling_group'"
}
which will produce something like this:
HTTP/1.1 200 OK
Content-Length: 550
Content-Type: application/json
[
{
"group": {
"flavor_id": "2",
"host": "compute1"
},
"measures": {
"measures": {
"aggregated": [
[
"2014-10-06T14:00:00+00:00",
3600.0,
43.333333333333336
],
[
"2014-10-06T14:34:00+00:00",
60.0,
58.0
],
[
"2014-10-06T14:34:12+00:00",
1.0,
80.0
],
[
"2014-10-06T14:34:20+00:00",
1.0,
36.0
]
]
}
}
},
{
"group": {
"flavor_id": "2",
"host": "compute2"
},
"measures": {
"measures": {
"aggregated": [
[
"2014-10-06T14:00:00+00:00",
3600.0,
58.4
],
[
"2014-10-06T14:30:00+00:00",
1800.0,
58.4
],
[
"2014-10-06T14:34:12+00:00",
1.0,
18.0
],
[
"2014-10-06T14:34:20+00:00",
1.0,
56.8
]
]
}
}
}
]
However, apart from not allowing to filter for metadata, the endpoint still produces measures (aggregated measures) instead of aggregated data.
There does not seem to be any way to produce the same data, although Gnocchi is mentioned as the updated substitute of Ceilometer in the OpenStack documentation.
Did anyone manage to find a way to replace the ceilometer endpoint?

I've got an answer through github through the official Gnocchi repository.
It looks like you cannot directly get the same output, although there are two possible strategies to get close to it:
Define an archive policy that matches the desired aggregation.
Perform the http requests for each stat and aggregate data manually later.
More about that can be directly found here

Related

Here maps: Routing - Calculate matrix response shows failed status for few inter combinations of starts to destinations in few countries

Making a Rest call to calculate matrix of HERE routing with multiple starts and destinations but getting proper response only for direct one to one start and destinations and getting status:failed for other inter combinations (getting only for principal diagonal values). Facing the issue only for few countries (here it is India) but working for the samples in the website (Europe)
Rest GET call: https://matrix.route.ls.hereapi.com/routing/7.2/calculatematrix.json?apiKey=<API_KEY>&mode=balanced;car;traffic:disabled&summaryAttributes=distance,traveltime&start0=17.251160,78.437737&destination0=16.506174,80.648018&start1=13.069166,80.191391&destination1=12.971599,77.594566
Response: {
"response": {
"metaInfo": {
"timestamp": "2020-02-04T12:36:09Z",
"mapVersion": "8.30.105.150",
"moduleVersion": "7.2.202005-6333",
"interfaceVersion": "2.6.75",
"availableMapVersion": [
"8.30.105.150"
]
},
"matrixEntry": [
{
"startIndex": 0,
"destinationIndex": 0,
"summary": {
"distance": 286827,
"travelTime": 24236,
"costFactor": 24029
}
},
{
"startIndex": 0,
"destinationIndex": 1,
"status": "failed"
},
{
"startIndex": 1,
"destinationIndex": 0,
"status": "failed"
},
{
"startIndex": 1,
"destinationIndex": 1,
"summary": {
"distance": 339029,
"travelTime": 26924,
"costFactor": 26845
}
}
]
}
}
The reason behind the observed behaviour is that the road network in
India is quite dense, and in some areas the algorithm is not able to
find an optimal route within a reasonable time limit.
We suggest trying out our Large Scale Matrix Service. It supports two use cases:
Matrix Routing calculations with live traffic information for matrices up to 10000x10000 size in a limited size region (up to 400km in diameter).
Matrix Routing calculations without live traffic information for matrices up to 10000x10000 size without region limitations for fixed sets of parameters (profiles).

Does SmartSheet support any CURL to get the total row count in a sheet?

I am using curl with REST to access Smartshets in my C# running on WIN CE. My application is supposed to dump some data on smartsheet periodically.
Before I write to a sheet, I would like to know the total row count in the sheet so that I don't exceed 5000 rows per sheet.
I am looking for an API that would return just row count given the sheet id?
Currently using below API which returns the entire sheet data and takes very long to fetch and format.
curl https://api.smartsheet.com/2.0/sheets/{sheetId}
with data of upto 5000 rows pr sheet, it takes very long to fetch and format below response to determine the available rows:
{
"id": 4583173393803140,
"name": "sheet 1",
"version": 6,
"totalRowCount": 240,
"accessLevel": "OWNER",
"effectiveAttachmentOptions": [
"EVERNOTE",
"GOOGLE_DRIVE",
"EGNYTE",
"FILE",
"ONEDRIVE",
"DROPBOX",
"BOX_COM"
],
"readOnly": true,
"ganttEnabled": true,
"dependenciesEnabled": true,
"resourceManagementEnabled": true,
"cellImageUploadEnabled": true,
"userSettings": {
"criticalPathEnabled": false,
"displaySummaryTasks": true
},
"userPermissions": {
"summaryPermissions": "ADMIN"
},
"workspace": {
"id": 825898975642500,
"name": "New Workspace"
},
"projectSettings": {
"workingDays": [
"MONDAY",
"TUESDAY",
"WEDNESDAY"
],
"nonWorkingDays": [],
"lengthOfDay": 8
},
"hasSummaryFields": false,
"permalink": "https://app.smartsheet.com/b/home?lx=pWNSDH9itjBXxBzFmyf-5w",
"createdAt": "2018-09-24T20:27:57Z",
"modifiedAt": "2018-09-26T20:45:08Z",
"columns": [
{
"id": 4583173393803140,
"version": 0,
"index": 0,
"primary": true,
"title": "Primary Column",
"type": "TEXT_NUMBER",
"validation": false
},
{
"id": 2331373580117892,
"version": 0,
"index": 1,
"options": [
"new",
"in progress",
"completed"
],
"title": "status",
"type": "PICKLIST",
"validation": true
}
],
"rows": Array[4962]....
}
Any help will b greatly appreciated.enter code here
There isn't a request to specifically return the number of rows on a Sheet. But, with any GET /sheets/{sheetId} operation the resulting Sheet object returned will have a top level totalRowCount attribute on it. So, you don't have to GET the sheet and count the objects in the rows array. Instead you can look to the totalRowCount attribute and the value there to know how many rows are currently on the sheet.
If you are concerned about pulling down all of the Sheet data you can use paging to keep from getting all of the data returned. Doing a GET /sheets/{sheetId}?pageSize=1 will give you the Sheet object with only the first row of data to help make the payload smaller. The totalRowCount attribute will still be present in the response.

WooCommerce REST API: updating order line item metadata for shipment

I've stubled upon an issue for updating order line items' metadata via WooCommerce REST API using node.js.
I've been following these steps for updating orders (and was succesful with some fields):
https://woocommerce.github.io/woocommerce-rest-api-docs/#update-an-order
Now, what I would like to achieve is changing the number of shipped line items of an order. Something I would normally use the partial orders WC plugin in the wordpress UI.
Below, you can find a screenshot of a line item I get from WC using the orders API call. The last element of the meta_data array has key 'shipped' and it contains an array with one object, stating that one (out of two ordered items) had been shipped:
"line_items": [{
"id": 1937,
"name": "Maya",
"product_id": 1271,
"variation_id": 1272,
"quantity": 2,
"tax_class": "",
"subtotal": "140.00",
"subtotal_tax": "0.00",
"total": "140.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": [{
"id": 21637,
"key": "pa_product-color",
"value": "beige"
}, {
"id": 21638,
"key": "pa_shoe-size",
"value": "42"
}, {
"id": 21639,
"key": "pa_shoe-width",
"value": "wide"
}, {
"id": 21640,
"key": "shipped",
"value": [{
"qty": 1,
"date": "Nov 21, 2017"
}
]
}
],
"sku": "2522BE42W",
"price": 70
},
As you can see, the value of the key 'shipped' is an object. When I ty to send it (back) to WC, I get an error saying:
"data":{"status":400,"params":{"line_items":"line_items[0][meta_data][3][value] is not of type string."}}}
When I try to send the value as a string, i.e.
lineItems[0].meta_data = [{key:"shipped", value: "[{qty:'2'}]" }]
I get no errors, but WC treats this as string, not as an object and doesn't update the shipment qty in the DB the way I intended (it only pulls the shipped quantity down to 0 instead):
{
"id": 21640,
"key": "shipped",
"value": "[{qty:'2'}]"
}
Any insights or ideas - how could I modify the shipped quantity of line items via the WC API?
So, apparently there was a bug in WP 4.9 version, which was fixed recently in the following commit:
https://github.com/woocommerce/woocommerce/pull/17849
It concerns REST API schema and after merging the fix to WooCommerce, the problems disappear and now I am able to send the data as an object.
More on the topic can be found here:
https://github.com/woocommerce/wc-api-dev/pull/74

How to use a HTTP HEAD request as health check for Marathon?

Look like the protocols HTTP or MESOS_HTTP only do GET request.
This works:
"healthChecks": [
{
"protocol": "COMMAND",
"command": "curl -I http://0.0.0.0:5000/",
"gracePeriodSeconds": 300,
"intervalSeconds": 60,
"timeoutSeconds": 20,
"maxConsecutiveFailures": 3
}
],
But I found it to much for such simple tasks... I would expect something simpler, something like "method":"HEAD":
"healthChecks": [
{
"protocol": "HTTP",
"path": "/",
"portIndex": 5000,
"method": "HEAD",
"gracePeriodSeconds": 300,
"intervalSeconds": 60,
"timeoutSeconds": 20,
"maxConsecutiveFailures": 3
}
],
If you need/want HTTP HEAD based health checks then COMMAND-based are your only option. The HTTP-based support GET only. See also the Marathon docs for more details.

how to get all bucket types in riak using http get

I know how to list all bucket types using command line .reference http://stackoverflow.com/questions/30785431/how-to-list-all-the-bucket-types-in-riak
But I need it using HTTP call
There is currently no way to list bucket types via HTTP. I can suggest two options:
Wrap the riak-admin bucket-types list command in a simple Web service and expose it via HTTP.
Install the experimental Riak Explorer, point it to your cluster, and use the bucket_types endpoint to list bucket types. For example, curl -X GET http://127.0.0.1:9000/explore/clusters/default/bucket_types should give you something like
{
"bucket_types": [{
"id": "default",
"props": {
"active": true,
"allow_mult": true,
"basic_quorum": false,
"big_vclock": 50,
"chash_keyfun": "{riak_core_util,chash_std_keyfun}",
"dvv_enabled": false,
"dw": "quorum",
"last_write_wins": false,
"linkfun": "{modfun,riak_kv_wm_link_walker,mapreduce_linkfun}",
"n_val": 3,
"notfound_ok": true,
"old_vclock": 86400,
"postcommit": [],
"pr": 0,
"precommit": [],
"pw": 0,
"r": "quorum",
"rw": "quorum",
"small_vclock": 50,
"w": "quorum",
"write_once": false,
"young_vclock": 20
}
}],
"links": {
"self": "/explore/clusters/default/bucket_types"
}
}

Resources