Class GroupedInfluxDbHttpSender

  • All Implemented Interfaces:
    InfluxDbSender

    public class GroupedInfluxDbHttpSender
    extends InfluxDbHttpSender
    Passthrough to ultimately select a different style of serializer: grouped fields on one influxdb protocol line, instead of one field per protocol line. This class will write out one protocol line per timestamp. For each point that occurred at a particular timestamp, a line is output in the following order with a comma delimiting the first two items and a space delimiting all other items: 1. measurementPrefix+groupMeasurement 2. tags (in the format of name=value) delimited by commas 3. each field is written prepended with a name that indicates its measurement delimited by commas. There is an assumption made here that the measurement naming convention is a set of strings delimited by a ".". In the case where there is at least two strings in the measurement name, the first string in that name is dropped. Also, if a particular point has only one field and that field has the key "value", the field name is dropped. 4. time (in milliseconds) To illustrate what is described above, here is an examples of what will be written for a given sets of points.

    EXAMPLE

     [
       // The first two points are intended to show how points with the same timestamp are merged.
       Point {
         measurement: confabulator.a.b.c,
         tags {
           foo: one,
           bar: two
         },
         time: 0,
         fields {
           temp: 10,
           bytes: 7
         }
       },
       Point {
         measurement: confabulator.x.y.z,
         tags {
           foo: one,
           bar: two
         },
         time: 0,
         fields {
           pressure: 50,
           status: good
         }
       },
       // This next point shows the example of when the field has one key called "value"
       Point {
         measurement: confabulator.file.size.max,
         tags {
           foo: one,
           bar: two
         },
         time: 1,
         fields {
           value = 10000000
         }
       },
       // This next point shows an example of what is written when measurement is only a single string
       Point {
         measurement: minimum,
         tags {
           foo: one,
           bar: two
         },
         time: 2,
         fields {
           memory: 64000,
           temperature: 98.6
         }
       }
     ]
     

    OUTPUT FOR ABOVE EXAMPLE

    Assuming that the value for the measurementPrefix is null and the groupMeasurement is the string "groupMeasurement", the output for the above example would result in three lines corresponding to the three unique timestamps. The lines would be as follows:
     groupMeasurement,foo=one,bar=two a.b.c.temp=10,a.b.c.bytes=7,x.y.z.pressure=50,x.y.z.status=good 0
     groupMeasurement,foo=one,bar=two file.size.max=10000000 1
     groupMeasurement,foo=one,bar=two minimum.memory=64000,minimum.temperature=98.6 2
     
    • Constructor Detail

      • GroupedInfluxDbHttpSender

        public GroupedInfluxDbHttpSender​(String protocol,
                                         String hostname,
                                         int port,
                                         String database,
                                         String authString,
                                         TimeUnit timePrecision,
                                         int connectTimeout,
                                         int readTimeout,
                                         String measurementPrefix,
                                         String groupMeasurement)
                                  throws Exception
        Creates a new http sender given connection details. This sender groups all the fields under one measurement and transmit them as one measurement.
        Parameters:
        protocol - the name of the protocol to use
        hostname - the influxDb hostname
        port - the influxDb http port
        database - the influxDb database to write to
        authString - the authorization string to be used to connect to InfluxDb, of format username:password
        timePrecision - the time precision of the metrics
        connectTimeout - the connect timeout
        readTimeout - the read timeout
        measurementPrefix - the measurement prefix
        groupMeasurement - the group measurement name
        Throws:
        Exception - exception while creating the influxDb sender(MalformedURLException)