org.influxdb.dto.Point.measurement()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(126)

本文整理了Java中org.influxdb.dto.Point.measurement()方法的一些代码示例,展示了Point.measurement()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Point.measurement()方法的具体详情如下:
包路径:org.influxdb.dto.Point
类名称:Point
方法名:measurement

Point.measurement介绍

[英]Create a new Point Build build to create a new Point in a fluent manner.
[中]创建新点Build以流畅的方式创建新点。

代码示例

代码示例来源:origin: apache/incubator-gobblin

private Point buildEventAsPoint(String name, Object value, long timestamp) throws IOException {
 return Point.measurement(name).field("value", value).time(timestamp, TimeUnit.MILLISECONDS).build();
}

代码示例来源:origin: apache/incubator-gobblin

private Point buildMetricAsPoint(String name, Object value, long timestamp) throws IOException {
 return Point.measurement(name).field("value", value).time(timestamp, TimeUnit.MILLISECONDS).build();
}

代码示例来源:origin: jmxtrans/jmxtrans

filteredValues.put(JMX_PORT_KEY, Integer.parseInt(server.getPort()));
Point point = Point.measurement(result.getKeyAlias()).time(result.getEpoch(), MILLISECONDS)
    .tag(resultTagsToApply).fields(filteredValues).build();

代码示例来源:origin: testcontainers/testcontainers-java

@Test
  public void queryForWriteAndRead() {
    InfluxDB influxDB = influxDBContainer.getNewInfluxDB();

    Point point = Point.measurement("cpu")
      .time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
      .addField("idle", 90L)
      .addField("user", 9L)
      .addField("system", 1L)
      .build();
    influxDB.write(point);

    Query query = new Query("SELECT idle FROM cpu", DATABASE);
    QueryResult actual = influxDB.query(query);

    assertThat(actual, notNullValue());
    assertThat(actual.getError(), nullValue());
    assertThat(actual.getResults(), notNullValue());
    assertThat(actual.getResults().size(), is(1));

  }
}

代码示例来源:origin: apache/cloudstack

/**
 * Sends host metrics to a configured InfluxDB host. The metrics respects the following specification.</br>
 * <b>Tags:</b>vm_id, uuid, instance_name, data_center_id, host_id</br>
 * <b>Fields:</b>memory_total_kb, memory_internal_free_kbs, memory_target_kbs, cpu_utilization, cpus, network_write_kb, disk_read_iops, disk_read_kbs, disk_write_iops, disk_write_kbs
 */
protected Point createInfluxDbPointForHostMetrics(Object metricsObject) {
  HostStatsEntry hostStatsEntry = (HostStatsEntry)metricsObject;
  Map<String, String> tagsToAdd = new HashMap<>();
  tagsToAdd.put(UUID_TAG, hostStatsEntry.getHostVo().getUuid());
  Map<String, Object> fieldsToAdd = new HashMap<>();
  fieldsToAdd.put(TOTAL_MEMORY_KBS_FIELD, hostStatsEntry.getTotalMemoryKBs());
  fieldsToAdd.put(FREE_MEMORY_KBS_FIELD, hostStatsEntry.getFreeMemoryKBs());
  fieldsToAdd.put(CPU_UTILIZATION_FIELD, hostStatsEntry.getCpuUtilization());
  fieldsToAdd.put(CPUS_FIELD, hostStatsEntry.getHostVo().getCpus());
  fieldsToAdd.put(CPU_SOCKETS_FIELD, hostStatsEntry.getHostVo().getCpuSockets());
  fieldsToAdd.put(NETWORK_READ_KBS_FIELD, hostStatsEntry.getNetworkReadKBs());
  fieldsToAdd.put(NETWORK_WRITE_KBS_FIELD, hostStatsEntry.getNetworkWriteKBs());
  return Point.measurement(INFLUXDB_HOST_MEASUREMENT).tag(tagsToAdd).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS).fields(fieldsToAdd).build();
}

代码示例来源:origin: apache/cloudstack

/**
 * Sends VMs metrics to a configured InfluxDB host. The metrics respects the following specification.</br>
 * <b>Tags:</b>vm_id, uuid, instance_name, data_center_id, host_id</br>
 * <b>Fields:</b>memory_total_kb, memory_internal_free_kbs, memory_target_kbs, cpu_utilization, cpus, network_write_kb, disk_read_iops, disk_read_kbs, disk_write_iops, disk_write_kbs
 */
protected Point createInfluxDbPointForVmMetrics(Object metricsObject) {
  VmStatsEntry vmStatsEntry = (VmStatsEntry)metricsObject;
  UserVmVO userVmVO = vmStatsEntry.getUserVmVO();
  Map<String, String> tagsToAdd = new HashMap<>();
  tagsToAdd.put(UUID_TAG, userVmVO.getUuid());
  Map<String, Object> fieldsToAdd = new HashMap<>();
  fieldsToAdd.put(TOTAL_MEMORY_KBS_FIELD, vmStatsEntry.getMemoryKBs());
  fieldsToAdd.put(FREE_MEMORY_KBS_FIELD, vmStatsEntry.getIntFreeMemoryKBs());
  fieldsToAdd.put(MEMORY_TARGET_KBS_FIELD, vmStatsEntry.getTargetMemoryKBs());
  fieldsToAdd.put(CPU_UTILIZATION_FIELD, vmStatsEntry.getCPUUtilization());
  fieldsToAdd.put(CPUS_FIELD, vmStatsEntry.getNumCPUs());
  fieldsToAdd.put(NETWORK_READ_KBS_FIELD, vmStatsEntry.getNetworkReadKBs());
  fieldsToAdd.put(NETWORK_WRITE_KBS_FIELD, vmStatsEntry.getNetworkWriteKBs());
  fieldsToAdd.put(DISK_READ_IOPS_FIELD, vmStatsEntry.getDiskReadIOs());
  fieldsToAdd.put(DISK_READ_KBS_FIELD, vmStatsEntry.getDiskReadKBs());
  fieldsToAdd.put(DISK_WRITE_IOPS_FIELD, vmStatsEntry.getDiskWriteIOs());
  fieldsToAdd.put(DISK_WRITE_KBS_FIELD, vmStatsEntry.getDiskWriteKBs());
  return Point.measurement(INFLUXDB_VM_MEASUREMENT).tag(tagsToAdd).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS).fields(fieldsToAdd).build();
}

代码示例来源:origin: influxdata/influxdb-java

TimeUnit timeUnit = getTimeUnit(modelType);
long time = timeUnit.convert(System.currentTimeMillis(), TimeUnit.MILLISECONDS);
Point.Builder pointBuilder = Point.measurement(measurement).time(time, timeUnit);

代码示例来源:origin: sitewhere/sitewhere

/**
 * Return a builder for the events collection.
 * 
 * @return
 * @throws SiteWhereException
 */
public static Point.Builder createBuilder() throws SiteWhereException {
return Point.measurement(COLLECTION_EVENTS);
}

代码示例来源:origin: Dromara/soul

/**
   * save data in influxDb.
   *
   * @param monitorDO {@linkplain MonitorDO}
   */
  public void writeData(final MonitorDO monitorDO) {
    final Point.Builder builder = Point.measurement("monitorDO")
        .time(System.currentTimeMillis(), TimeUnit.MILLISECONDS);
    builder.tag("host", monitorDO.getHost())
        .tag("ip", monitorDO.getIp())
        .tag("method", monitorDO.getMethod())
        .tag("module", monitorDO.getModule())
        .tag("resultType", monitorDO.getResultType())
        .tag("rpcType", monitorDO.getRpcType())
        .addField("count", monitorDO.getCount());
    final Point point = builder.build();
    influxDBTemplate.write(point);
  }
}

代码示例来源:origin: org.apache.camel/camel-influxdb

@Converter
public static Point fromMapToPoint(Map<String, Object> map) {
  Object measurenmentName = map.get(InfluxDbConstants.MEASUREMENT_NAME);
  if (measurenmentName == null) {
    String format = String.format("Unable to find the header for the measurement in:" + map.keySet().toString());
    throw new CamelInfluxDbException(format);
  }
  String measurenmentNameString = measurenmentName.toString();
  Point.Builder pointBuilder = Point.measurement(measurenmentNameString);
  map.remove(InfluxDbConstants.MEASUREMENT_NAME);
  pointBuilder.fields(map);
  map.put(InfluxDbConstants.MEASUREMENT_NAME, measurenmentName);
  return pointBuilder.build();
}

代码示例来源:origin: etsy/statsd-jvm-profiler

private Point   constructPoint(long time, String key, Number value) {
    Point.Builder builder = Point.measurement(key)
        .time(time, TimeUnit.MILLISECONDS)
        .field(VALUE_COLUMN, value);
    for (Map.Entry<String, String> entry : tags.entrySet()) {
      builder = builder.tag(entry.getKey(), entry.getValue());
    }

    return builder.build();
  }
}

代码示例来源:origin: Scrin/RuuviCollector

private static void createAndAddLegacyFormatPointIfNotNull(List<Point> points, String measurement, Number value, String extraTagKey, String extraTagValue) {
    if (value != null) {
      Point.Builder p = Point.measurement(measurement).addField("value", value);
      if (extraTagValue != null) {
        p.tag(extraTagKey, extraTagValue);
      }
      points.add(p.build());
    }
  }
}

代码示例来源:origin: org.apache.gobblin/gobblin-metrics-influxdb

private Point buildMetricAsPoint(String name, Object value, long timestamp) throws IOException {
 return Point.measurement(name).field("value", value).time(timestamp, TimeUnit.MILLISECONDS).build();
}

代码示例来源:origin: NightscoutFoundation/xDrip

private Point createMeterPoint(Calibration record) {
  return Point.measurement("meter")
      .time(record.timestamp, TimeUnit.MILLISECONDS)
      .tag("device", "xDrip-" + prefs.getString("dex_collection_method", "BluetoothWixel"))
      .tag("type", "mbg")
      .addField("mbg", record.bg)
      .build();
}

代码示例来源:origin: jamorham/xDrip-plus

private Point createMeterPoint(Calibration record) {
  return Point.measurement("meter")
      .time(record.timestamp, TimeUnit.MILLISECONDS)
      .tag("device", "xDrip-" + prefs.getString("dex_collection_method", "BluetoothWixel"))
      .tag("type", "mbg")
      .addField("mbg", record.bg)
      .build();
}

代码示例来源:origin: inspectIT/inspectIT

@Test
  public void mustToCallToInsertDBDao() {
    Builder builder = Point.measurement("test").addField("test", 1).time(1, TimeUnit.MILLISECONDS);
    when(diagnosisCmrConfiguration.problemOccurrencePointBuilder.getBuilder(problemOccurrence)).thenReturn(builder);
    diagnosisCmrConfiguration.accept(problemOccurrence);
    ArgumentCaptor<Point> pointCaptor = ArgumentCaptor.forClass(Point.class);
    verify(diagnosisCmrConfiguration.influxDBDao).insert(pointCaptor.capture());
    assertThat(pointCaptor.getValue().lineProtocol(), is(builder.build().lineProtocol()));
  }
}

代码示例来源:origin: inspectIT/inspectIT

/**
 * {@inheritDoc}
 */
@Override
public Collection<Builder> build(UserSessionInfo sessionInfo, PageLoadRequest plr, ResourceLoadRequest res) {
  Builder builder = Point.measurement(Series.EumResourceLoad.NAME);
  super.addBasicRequestData(builder, sessionInfo, res);
  builder.tag(Series.EumResourceLoad.TAG_INITIATOR_URL, res.getBaseUrl());
  builder.tag(Series.EumResourceLoad.TAG_INITIATOR_TYPE, res.getInitiatorType());
  builder.time(res.getOwningSpan().getTimeStamp().getTime(), TimeUnit.MILLISECONDS);
  builder.addField(Series.EumAjax.FIELD_DURATION, res.getOwningSpan().getDuration());
  builder.addField(Series.EumResourceLoad.FIELD_TRANSFER_SIZE, res.getTransferSize());
  return Collections.singleton(builder);
}

代码示例来源:origin: inspectIT/inspectIT

/**
 * {@inheritDoc}
 */
@Override
public Collection<Builder> build(UserSessionInfo sessionInfo, PageLoadRequest plr, AjaxRequest ajax) {
  Builder builder = Point.measurement(Series.EumAjax.NAME);
  addBasicRequestData(builder, sessionInfo, ajax);
  builder.tag(Series.EumAjax.TAG_BASE_URL, ajax.getBaseUrl());
  builder.time(ajax.getOwningSpan().getTimeStamp().getTime(), TimeUnit.MILLISECONDS);
  builder.addField(Series.EumAjax.FIELD_DURATION, ajax.getOwningSpan().getDuration());
  builder.addField(Series.EumAjax.FIELD_METHOD, ajax.getMethod());
  builder.addField(Series.EumAjax.FIELD_STATUS, ajax.getStatus());
  return Collections.singleton(builder);
}

代码示例来源:origin: dataArtisans/flink-training-exercises

@Override
  public void invoke(T dataPoint, SinkFunction.Context context) throws Exception {
    Point.Builder builder = Point.measurement(measurement)
        .time(dataPoint.getTimeStampMs(), TimeUnit.MILLISECONDS)
        .addField(this.fieldName, dataPoint.getValue());

    if(dataPoint instanceof KeyedDataPoint){
      builder.tag("key", ((KeyedDataPoint) dataPoint).getKey());
    }

    Point p = builder.build();

    influxDB.write(DEFAULT_DATABASE_NAME, "autogen", p);
  }
}

代码示例来源:origin: dataArtisans/oscon

@Override
 public void invoke(T dataPoint, Context context) throws Exception {
  Point.Builder builder = Point.measurement(measurement)
      .time(dataPoint.getTimeStampMs(), TimeUnit.MILLISECONDS)
      .addField(fieldName, dataPoint.getValue());

  if(dataPoint instanceof KeyedDataPoint){
   builder.tag("key", ((KeyedDataPoint) dataPoint).getKey());
  }

  Point p = builder.build();

  influxDB.write(dataBaseName, "autogen", p);

 }
}

相关文章