Skip to content

Commit 8ae55ae

Browse files
committed
Adding readme
1 parent 9ec3ce8 commit 8ae55ae

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# InfluxDB DWH Exporter
2+
3+
This application provides an HTTP endpoint that can deliver metrics from an InfluxDB in an aggregated form when called.
4+
5+
This can be used to provide an aggregated view of existing metrics or derived ones to an external tool (e.g. data warehouse or other databases).
6+
7+
## Usage
8+
9+
The endpoint which is provided and through which the metrics can be retrieved/exported is `/dwh`
10+
11+
| Parameter | Example | Description |
12+
| ------------- |:-------------:| -----:|
13+
| `token`| `/dwh?token=my_secret`| `token` must match the token configured in the `application.yml`, otherwise access will be denied. |
14+
| `interval`| `/dwh?interval=5m`| Specifies the resolution in which the metrics are provided. This corresponds to the `${interval}` variable in the configured queries. If interval is not specified, the default value `1m` is used, i.e. a resolution per minute. |
15+
| `range`| `/dwh?range=2h`| Defines the time period that the metrics should cover. For example, `2h` means that the data points of the metrics of the last two hours should be queried. This variable is used to define `${timeFilter}` in the configured queries. If range is not specified, the data for one interval will be returned. |
16+
| `offset`| `/dwh?offset=5m`| Defines a time offset with which the data should be queried. For example, if the data is queried at 15:00, it is possible that the data for 14:59 has not yet arrived in the InfluxDB. By using offset, the query interval can now be shifted into the past. If offset is not defined, an offset of one minute is used. |
17+
| `start` & `end`| `/dwh?start=1587023100000&end=1587023400000`| Alternative way to specify the time period compared to range and offset. The values start and end must be epoch timestamps in milliseconds. It is also important that both start and end are multiples of the interval. I.e. for example with an interval of 1m both timestamps must be divisible by 60000 without remainder. |
18+
19+
#### Examples
20+
21+
`/dwh?token=my_secret` - Returns the data of the last minute in minute resolution with an offset of one minute.
22+
23+
`/dwh?token=my_secret&interval=15m` - Returns the data of the last 15 minutes in a 15-minute resolution with an offset of one minute.
24+
25+
`/dwh?token=my_secret&interval=15m&range=60m&offset=5m` - Returns the data of the last 60 minutes in a 15-minute resolution with an offset of five minutes.
26+
27+
`/dwh?token=my_secret&interval=1m&start=1587023340000&end1587023400000` - Returns the data between defined the timestamps in a 1-minute resolution.
28+
29+
## Configuration
30+
31+
The configuration of the provided metrics can be done via an `application.yml` file, which can be put in the working directory of the application.
32+
33+
The following code is an example for the `application.yml`.
34+
For a full list of available configurations, see the default [application.yml](https://github.com/NovatecConsulting/influxdb-dwh-exporter/blob/main/src/main/resources/application.yml):
35+
36+
```yaml
37+
server:
38+
# the port of the server
39+
port: 8080
40+
41+
spring:
42+
influx:
43+
# URL of the InfluxDB
44+
url: http://localhost:8086
45+
# username for the InfluxDB
46+
user: ""
47+
# password for the InfluxDB
48+
password: ""
49+
50+
dwh:
51+
# secret to access the /dwh endpoint
52+
token: my_secret
53+
54+
# the metrics and related queries to use and export
55+
metrics:
56+
- name: my-metric|${service}|${http_path}
57+
query: |
58+
SELECT SUM("sum") / SUM("count")
59+
FROM "inspectit"."autogen"."http_in_responsetime"
60+
GROUP BY time(${interval}), "service", "http_path" FILL(null)
61+
```
62+
63+
### Metrics Configuration
64+
65+
A list of metrics that will be provided via the HTTP endpoint can be specified in `dwh.metrics`.
66+
Two parameters must be defined for each metric: `name` and `query`.
67+
68+
`name` is the name of the resulting "metric view".
69+
The name can be parameterized using the tags of the underlying metric, as shown in the example above using `${service}` and `${http_path}`.
70+
71+
`query` is the InfluxDB query that is executed to retrieve the corresponding metric from InfluxDB.
72+
Here, the variable `${timeFilter}` should be used in the WHERE clause.
73+
Also, `{interval}` should be used as "GROUP BY time" interval!
74+
75+
It is important that **exactly** the tags used for parameterization in `name` are also used in the GROUP BY-clause!
76+
77+
When the endpoint provided by the application is called, the exporter executes **all** configured queries and returns the corresponding result.
78+
79+
### Health Endpoint
80+
81+
The application provides an endpoint under `/actuator/health that can be used to check if the application is running and the InfluxDB is available.
82+
83+
By default, only a simple status is provided:
84+
```
85+
{
86+
"status":"UP",
87+
}
88+
```
89+
90+
However, with the following configuration, additional information, such as status of the InfluxDB connection, can be obtained via the health endpoint:
91+
```
92+
management:
93+
endpoint:
94+
health:
95+
show-details: "ALWAYS"
96+
```
97+
98+
Using this configuration, the health endpoint provides the following result:
99+
```
100+
{
101+
"status":"UP",
102+
"components": {
103+
"influxDb": {
104+
"status":"UP"
105+
}
106+
}
107+
}
108+
```

0 commit comments

Comments
 (0)