com.googlecode.jmxtrans.model.output.InfluxDbWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmxtrans-output-influxdb Show documentation
Show all versions of jmxtrans-output-influxdb Show documentation
This module contains InfluxDB output writers.
/**
* The MIT License
* Copyright (c) 2010 JmxTrans team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.googlecode.jmxtrans.model.output;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.googlecode.jmxtrans.model.OutputWriterAdapter;
import com.googlecode.jmxtrans.model.Query;
import com.googlecode.jmxtrans.model.Result;
import com.googlecode.jmxtrans.model.ResultAttribute;
import com.googlecode.jmxtrans.model.Server;
import org.influxdb.InfluxDB;
import org.influxdb.InfluxDB.ConsistencyLevel;
import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.ThreadSafe;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
import static com.google.common.collect.Maps.newHashMap;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
/**
* {@link com.googlecode.jmxtrans.model.OutputWriter} for
* InfluxDB.
*
* @author Simon Hutchinson
* github.com/sihutch
*/
@ThreadSafe
public class InfluxDbWriter extends OutputWriterAdapter {
public static final String TAG_HOSTNAME = "hostname";
@Nonnull private final InfluxDB influxDB;
@Nonnull private final String database;
@Nonnull private final ConsistencyLevel writeConsistency;
@Nonnull private final String retentionPolicy;
/**
* The {@link ImmutableSet} of {@link ResultAttribute} attributes of
* {@link Result} that will be written as {@link Point} tags
*/
private final ImmutableSet resultAttributesToWriteAsTags;
private final boolean createDatabase;
public InfluxDbWriter(
@Nonnull InfluxDB influxDB,
@Nonnull String database,
@Nonnull ConsistencyLevel writeConsistency,
@Nonnull String retentionPolicy,
@Nonnull ImmutableSet resultAttributesToWriteAsTags,
boolean createDatabase) {
this.database = database;
this.writeConsistency = writeConsistency;
this.retentionPolicy = retentionPolicy;
this.influxDB = influxDB;
this.resultAttributesToWriteAsTags = resultAttributesToWriteAsTags;
this.createDatabase = createDatabase;
}
Predicate
© 2015 - 2024 Weber Informatics LLC | Privacy Policy