This repository was archived by the owner on Jun 12, 2019. It is now read-only.
File tree 9 files changed +61
-53
lines changed
9 files changed +61
-53
lines changed Original file line number Diff line number Diff line change 1
- ## IoT PAAS API put/query/utils bash functions .
1
+ ## Bash functions for the Metrics data platform API .
2
2
3
3
Create a [ ` creds ` ] ( creds.example ) file with your tokens info.
4
4
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:
6
6
7
- #!/bin/bash
8
- set -euo pipefail
7
+ ```
8
+ #!/bin/bash
9
+ set -euo pipefail
9
10
10
- source lib/iot-lib.sh
11
+ source lib/metrics-functions.sh
12
+ ```
11
13
12
14
### Put
13
15
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
+ ```
20
24
21
25
Or send key: value list with ` kv_to_put_json ` function:
22
26
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
+ ```
28
34
29
35
### Query
30
36
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
+ ```
40
48
41
49
### Delete
42
50
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
+ ```
52
62
53
63
### List Metrics
54
64
65
+ ```
55
66
listMetrics
56
-
57
- returns all metrics for the current application
67
+ ```
Original file line number Diff line number Diff line change 1
1
#
2
- # IoT creds
2
+ # Metrics data platform creds
3
3
#
4
4
5
- # https://cloud.runabove .com/#/iot/ <your_app>
5
+ # https://www.ovh .com/manager/cloud/index.html#/paas/dbaas/timeseries/project/ <your_app>/keys
6
6
7
7
READ_TOKEN_ID=
8
8
READ_TOKEN_KEY=
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
set -euo pipefail
3
3
4
- source lib/iot-lib .sh
4
+ source lib/metrics-functions .sh
5
5
6
6
# @param metric the metric to query
7
7
# @param startDate the date to start the query (default: 0)
@@ -12,7 +12,7 @@ delete_query() {
12
12
local metric=$1
13
13
local startDate=${2:- 0}
14
14
local downSample=${3:- 10s}
15
-
15
+
16
16
echo ' {
17
17
"start":' $startDate ' ,
18
18
"queries":[{
Original file line number Diff line number Diff line change 1
1
#
2
- # IoT PAAS API put/query/utils bash functions.
2
+ # Metrics data plaform API put/query/utils bash functions.
3
3
#
4
4
5
- IOT_API=https://opentsdb.iot.runabove.io
5
+ IOT_API=https://opentsdb-gra1.tsaas.ovh.com
6
6
OPTS=" -w {\" status\" :%{http_code},\" time\" :%{time_total}}\n"
7
7
8
8
[ ! -f creds ] && echo " error: please setup a creds file with write/read id and key tokens" && exit 1
@@ -34,7 +34,7 @@ query() {
34
34
35
35
# Delete data from query
36
36
#
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)
38
38
#
39
39
delete () {
40
40
curl -s \
@@ -44,7 +44,7 @@ delete() {
44
44
$OPTS
45
45
}
46
46
47
- # Get metrics
47
+ # Get metrics list
48
48
#
49
49
# @param none
50
50
#
@@ -69,7 +69,7 @@ kv_to_put_json() {
69
69
local now=$( date +%s)
70
70
local comma=' '
71
71
local tags=' "tags":' " $tag "
72
-
72
+
73
73
echo ' ['
74
74
while read line
75
75
do
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
set -euo pipefail
3
3
4
- source lib/iot-lib .sh
4
+ source lib/metrics-functions .sh
5
5
6
6
#
7
7
# @return a JSON object representing an OpenTSDB suggest metrics query
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
set -euo pipefail
3
3
4
- source lib/iot-lib .sh
4
+ source lib/metrics-functions .sh
5
5
6
6
# Put and Query
7
7
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
set -euo pipefail
3
3
4
- source lib/iot-lib .sh
4
+ source lib/metrics-functions .sh
5
5
6
6
./probes/sys.sh \
7
7
| kv_to_put_json ' {"host":"' $HOSTNAME ' "}' \
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
set -euo pipefail
3
3
4
- source lib/iot-lib .sh
4
+ source lib/metrics-functions .sh
5
5
6
6
# @param metric the metric to query
7
7
# @param startDate the date to start the query (default: 0)
@@ -11,7 +11,7 @@ source lib/iot-lib.sh
11
11
json_avg_query () {
12
12
local metric=$1
13
13
local startDate=${2:- 0}
14
-
14
+
15
15
echo ' {
16
16
"start":' $startDate ' ,
17
17
"queries":[{
Original file line number Diff line number Diff line change 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.
You can’t perform that action at this time.
0 commit comments