@@ -12,23 +12,23 @@ Sending metrics is done by using the MetricBuilder. You simply add a metric, the
12
12
the data points.
13
13
14
14
15
- MetricBuilder builder = MetricBuilder.getInstance();
16
- builder.addMetric("metric1")
17
- .addTag("host", "server1")
18
- .addTag("customer", "Acme")
19
- .addDataPoint(System.currentTimeMillis(), 10)
20
- .addDataPoint(System.currentTimeMillis(), 30L);
15
+ MetricBuilder builder = MetricBuilder.getInstance();
16
+ builder.addMetric("metric1")
17
+ .addTag("host", "server1")
18
+ .addTag("customer", "Acme")
19
+ .addDataPoint(System.currentTimeMillis(), 10)
20
+ .addDataPoint(System.currentTimeMillis(), 30L);
21
21
HttpClient client = new HttpClient("http://localhost:8080");
22
- Response response = client.pushMetrics(builder);
23
- client.shutdown();
22
+ Response response = client.pushMetrics(builder);
23
+ client.shutdown();
24
24
25
25
## Querying Data Points
26
26
27
27
Querying data points is similarly done by using the QueryBuilder class. A query requires a date range. The start date is
28
28
required, but the end date defaults to NOW if not specified. The metric(s) that you are querying for is also required.
29
29
Optionally, tags may be added to narrow down the search.
30
30
31
- QueryBuilder builder = QueryBuilder.getInstance();
31
+ QueryBuilder builder = QueryBuilder.getInstance();
32
32
builder.setStart(2, TimeUnit.MONTHS)
33
33
.setEnd(1, TimeUnit.MONTHS)
34
34
.addMetric("metric1")
@@ -43,7 +43,7 @@ Querying metric tags is done by using the QueryTagBuilder class. A query require
43
43
required, but the end date defaults to NOW if not specified. The metric(s) that you are querying for is also required.
44
44
Optionally, tags may be added to narrow down the search.
45
45
46
- QueryTagBuilder builder = QueryTagBuilder.getInstance();
46
+ QueryTagBuilder builder = QueryTagBuilder.getInstance();
47
47
builder.setStart(2, TimeUnit.MONTHS)
48
48
.setEnd(1, TimeUnit.MONTHS)
49
49
.addMetric("metric1")
@@ -55,45 +55,77 @@ Optionally, tags may be added to narrow down the search.
55
55
56
56
You can get a list of all metric names in KairosDB.
57
57
58
- HttpClient client = new HttpClient("http://localhost:8080");
59
- GetResponse response = client.getMetricNames();
58
+ HttpClient client = new HttpClient("http://localhost:8080");
59
+ GetResponse response = client.getMetricNames();
60
60
61
- System.out.println("Response Code =" + response.getStatusCode());
62
- for (String name : response.getResults())
61
+ System.out.println("Response Code =" + response.getStatusCode());
62
+ for (String name : response.getResults())
63
63
{
64
- System.out.println(name);
64
+ System.out.println(name);
65
65
}
66
- client.shutdown();
66
+ client.shutdown();
67
67
68
68
## Querying Tag Names
69
+
69
70
Similarly you can get a list of all tag names in KairosDB.
70
71
71
- HttpClient client = new HttpClient("http://localhost:8080");
72
- GetResponse response = client.getTagNames();
72
+ HttpClient client = new HttpClient("http://localhost:8080");
73
+ GetResponse response = client.getTagNames();
73
74
74
- System.out.println("response=" + response.getStatusCode());
75
- for (String name : response.getResults())
76
- {
77
- System.out.println(name);
78
- }
79
- client.shutdown();
75
+ System.out.println("response=" + response.getStatusCode());
76
+ for (String name : response.getResults())
77
+ {
78
+ System.out.println(name);
79
+ }
80
+ client.shutdown();
80
81
81
82
## Querying Tag Values
83
+
82
84
And a list of all tag values.
83
85
84
- HttpClient client = new HttpClient("http://localhost:8080");
85
- GetResponse response = client.getTagValues();
86
+ HttpClient client = new HttpClient("http://localhost:8080");
87
+ GetResponse response = client.getTagValues();
86
88
87
- System.out.println("response=" + response.getStatusCode());
88
- for (String name : response.getResults())
89
+ System.out.println("response=" + response.getStatusCode());
90
+ for (String name : response.getResults())
89
91
{
90
- System.out.println(name);
92
+ System.out.println(name);
91
93
}
92
- client.shutdown();
93
-
94
+ client.shutdown();
95
+
94
96
## Create Roll-up Task
95
97
98
+ You can get of a list of roll-up tasks using the RollupBuilder.
99
+
100
+ RollupBuilder builder = RollupBuilder.getInstance("Metric1_rollupTask", new RelativeTime(1, TimeUnit.DAYS));
101
+ Rollup rollup1 = builder.addRollup("metric1_rollup");
102
+ QueryBuilder builder1 = rollup1.addQuery();
103
+ builder1.setStart(1, TimeUnit.HOURS);
104
+ builder1.addMetric("metric1")
105
+ .addAggregator(AggregatorFactory.createMaxAggregator(1, TimeUnit.MINUTES));
106
+ client.createRollup(builder);
107
+ client.shutdown();
108
+
109
+ ## Get Roll-up Task
110
+
111
+ Or just get a specified roll-up task
112
+
113
+ RollupResponse rollupResponse = client.getRollupTask("ddafbb87-3063-4013-8e98-da2ff8671caf");
114
+ for (RollupTask rollupTask : rollupResponse.getRollupTasks())
115
+ {
116
+ for (Rollup rollup : rollupTask.getRollups())
117
+ {
118
+ System.out.println(rollup);
119
+ }
120
+ }
121
+ client.shutdown();
122
+
123
+ ## Delete Roll-up task
124
+
125
+ Or delete a roll-up task
96
126
127
+ Response response = client.deleteRollup("ddafbb87-3063-4013-8e98-da2ff8671caf");
128
+ client.shutdown();
97
129
98
130
## Custom Data Types
99
131
Starting with version 0.9.4 of KairosDB, you can store more than just numbers as values. This version of the client
@@ -159,7 +191,7 @@ Last, you must cast to your new type following a query for a metric.
159
191
160
192
## KairosDB compatibility
161
193
162
- Version 2.2 .0 of the client was tested with KairosDB version 1.1.3 -1.
194
+ Version 2.3 .0 of the client was tested with KairosDB version 1.2.1 -1.
163
195
164
196
## Contributions
165
197
0 commit comments