Skip to content

Commit

Permalink
#35: Added docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bednar committed Jun 27, 2019
1 parent 738fce4 commit 6e0c6d3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Features
1. [#34](https://github.com/bonitoo-io/influxdb-client-java/issues/34): Auto-configure client from configuration file
1. [#35](https://github.com/bonitoo-io/influxdb-client-java/issues/35): Possibility to specify default tags

## 1.0.0.M1

Expand Down
46 changes: 45 additions & 1 deletion client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ The reference Java client that allows query, write and management (bucket, organ
- [Writing data using](#writes)
- [Line Protocol](#by-lineprotocol)
- [Data Point](#by-data-point)
- [POJO](#by-measurement)
- [POJO](#by-pojo)
- [Default Tags](#default-tags)
- [InfluxDB 2.0 Management API](#management-api)
- sources, buckets
- tasks
- authorizations
- health check
- [Advanced Usage](#advanced-usage)
- [Client configuration file](#client-configuration-file)
- [Client connection string](#client-connection-string)
- [Gzip support](#gzip-support)

## Queries

Expand Down Expand Up @@ -509,6 +513,46 @@ public class WriteLineProtocol {
}
```

#### Default Tags

Sometimes is useful to store same information in every measurement e.g. `hostname`, `location`, `customer`.
The client is able to use static value, system property or env property as a tag value.

The expressions:
- `California Miner` - static value
- `${version}` - system property
- `${env.hostname}` - environment property

##### Via Configuration file

In a [configuration file](#client-configuration-file) you are able to specify default tags by `influx2.measurement` prefix.

```properties
influx2.measurement.mine-sensor.tags.id = 132-987-655
influx2.measurement.mine-sensor.tags.customer = California Miner
influx2.measurement.mine-sensor.tags.hostname = ${env.hostname}
influx2.measurement.mine-sensor.tags.sensor-version = ${version}
```

##### Via API

```java
WriteOptions writeOptions = WriteOptions.builder()
.batchSize(10_000)
.flushInterval(500)
.addDefaultTag("mine-sensor", "id", "132-987-655")
.addDefaultTag("mine-sensor", "customer", "California Miner")
.addDefaultTag("mine-sensor", "hostname", "${env.hostname}")
.addDefaultTag("mine-sensor", "sensor-version", "${version}")
.build();
```

Both of configurations will produce the Line protocol:

```
mine-sensor,id=132-987-655,customer="California Miner",hostname=example.com,sensor-version=v1.00 altitude=10
```

### Handle the Events

#### Handle the Success write
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ public InfluxDBClientOptions.Builder connectionString(@Nonnull final String conn
@Nonnull
public InfluxDBClientOptions.Builder loadProperties() {


try (InputStream inputStream = this.getClass().getResourceAsStream("/influx2.properties")) {

Properties properties = new Properties();
Expand Down

0 comments on commit 6e0c6d3

Please sign in to comment.