Skip to content
This repository was archived by the owner on Jun 12, 2019. It is now read-only.

Commit c45d50b

Browse files
author
Thibault Richard
committed
Small doc improvements
Signed-off-by: Thibault Richard <thibault.richard@corp.ovh.com>
1 parent b2ee32b commit c45d50b

9 files changed

+61
-53
lines changed

Bash/README.md

+46-36
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,67 @@
1-
## IoT PAAS API put/query/utils bash functions.
1+
## Bash functions for the Metrics data platform API.
22

33
Create a [`creds`](creds.example) file with your tokens info.
44

5-
Source [lib/iot.lib.sh](lib/iot-lib.sh) and write some Bash:
5+
Source [lib/metrics-functions.sh](lib/metrics-functions.sh) and write some Bash:
66

7-
#!/bin/bash
8-
set -euo pipefail
7+
```
8+
#!/bin/bash
9+
set -euo pipefail
910
10-
source lib/iot-lib.sh
11+
source lib/metrics-functions.sh
12+
```
1113

1214
### Put
1315

14-
echo '{
15-
"metric":"foo",
16-
"timestamp":'$(date +%s)',
17-
"value":'0.$RANDOM',
18-
"tags":{}
19-
}' | put
16+
```
17+
echo '{
18+
"metric":"foo",
19+
"timestamp":'$(date +%s)',
20+
"value":'0.$RANDOM',
21+
"tags":{}
22+
}' | put
23+
```
2024

2125
Or send key:value list with `kv_to_put_json` function:
2226

23-
echo '\
24-
foo:42
25-
bar:123' \
26-
| kv_to_put_json \
27-
| put
27+
```
28+
echo '\
29+
foo:42
30+
bar:123' \
31+
| kv_to_put_json \
32+
| put
33+
```
2834

2935
### Query
3036

31-
echo '{
32-
"start":0,
33-
"queries":[{
34-
"metric":"foo",
35-
"aggregator":"avg",
36-
"downsample":"10s-avg",
37-
"tags":{}
38-
}]
39-
}' | query
37+
```
38+
echo '{
39+
"start":0,
40+
"queries":[{
41+
"metric":"foo",
42+
"aggregator":"avg",
43+
"downsample":"10s-avg",
44+
"tags":{}
45+
}]
46+
}' | query
47+
```
4048

4149
### Delete
4250

43-
echo '{
44-
"start":0,
45-
"queries":[{
46-
"metric":"foo",
47-
"aggregator":"avg",
48-
"downsample":"10s-avg",
49-
"tags":{}
50-
}]
51-
}' | delete
51+
```
52+
echo '{
53+
"start":0,
54+
"queries":[{
55+
"metric":"foo",
56+
"aggregator":"avg",
57+
"downsample":"10s-avg",
58+
"tags":{}
59+
}]
60+
}' | delete
61+
```
5262

5363
### List Metrics
5464

65+
```
5566
listMetrics
56-
57-
returns all metrics for the current application
67+
```

Bash/creds.example

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#
2-
# IoT creds
2+
# Metrics data platform creds
33
#
44

5-
# https://cloud.runabove.com/#/iot/<your_app>
5+
# https://www.ovh.com/manager/cloud/index.html#/paas/dbaas/timeseries/project/<your_app>/keys
66

77
READ_TOKEN_ID=
88
READ_TOKEN_KEY=

Bash/delete

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
source lib/iot-lib.sh
4+
source lib/metrics-functions.sh
55

66
# @param metric the metric to query
77
# @param startDate the date to start the query (default: 0)
@@ -12,7 +12,7 @@ delete_query() {
1212
local metric=$1
1313
local startDate=${2:-0}
1414
local downSample=${3:-10s}
15-
15+
1616
echo '{
1717
"start":'$startDate',
1818
"queries":[{

Bash/lib/iot-lib.sh Bash/lib/metrics-functions.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#
2-
# IoT PAAS API put/query/utils bash functions.
2+
# Metrics data plaform API put/query/utils bash functions.
33
#
44

5-
IOT_API=https://opentsdb.iot.runabove.io
5+
IOT_API=https://opentsdb-gra1.tsaas.ovh.com
66
OPTS="-w {\"status\":%{http_code},\"time\":%{time_total}}\n"
77

88
[ ! -f creds ] && echo "error: please setup a creds file with write/read id and key tokens" && exit 1
@@ -34,7 +34,7 @@ query() {
3434

3535
# Delete data from query
3636
#
37-
# @param stdin JSON data to query (http://opentsdb.net/docs/build/html/api_http/query.html)
37+
# @param stdin JSON data to delete (http://opentsdb.net/docs/build/html/api_http/query.html)
3838
#
3939
delete() {
4040
curl -s \
@@ -44,7 +44,7 @@ delete() {
4444
$OPTS
4545
}
4646

47-
# Get metrics
47+
# Get metrics list
4848
#
4949
# @param none
5050
#
@@ -69,7 +69,7 @@ kv_to_put_json() {
6969
local now=$(date +%s)
7070
local comma=''
7171
local tags='"tags":'"$tag"
72-
72+
7373
echo '['
7474
while read line
7575
do

Bash/list-metrics

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
source lib/iot-lib.sh
4+
source lib/metrics-functions.sh
55

66
#
77
# @return a JSON object representing an OpenTSDB suggest metrics query

Bash/put-n-query-foo-bar

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
source lib/iot-lib.sh
4+
source lib/metrics-functions.sh
55

66
# Put and Query
77

Bash/put-sys

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
source lib/iot-lib.sh
4+
source lib/metrics-functions.sh
55

66
./probes/sys.sh \
77
| kv_to_put_json '{"host":"'$HOSTNAME'"}' \

Bash/query

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
source lib/iot-lib.sh
4+
source lib/metrics-functions.sh
55

66
# @param metric the metric to query
77
# @param startDate the date to start the query (default: 0)
@@ -11,7 +11,7 @@ source lib/iot-lib.sh
1111
json_avg_query() {
1212
local metric=$1
1313
local startDate=${2:-0}
14-
14+
1515
echo '{
1616
"start":'$startDate',
1717
"queries":[{

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
This repository contains examples of how to push data to the Runabove IoT metrics storage in different languages.
2-
3-
The metrics storage uses the OpenTSDB API, and read-made libraries already exist in most languages.
1+
This repository contains examples of how to push data to the OVH Metrics Data platform in different languages.

0 commit comments

Comments
 (0)