Search in sources :

Example 41 with TimeSeries

use of com.google.bigtable.repackaged.com.google.monitoring.v3.TimeSeries in project spf4j by zolyfarkas.

the class TimeSeriesDatabase method createCountJFreeChart.

public JFreeChart createCountJFreeChart(final String tableName, final long startTime, final long endTime) throws IOException {
    TSTable info = this.getTSTable(tableName);
    TimeSeries data = this.read(tableName, startTime, endTime);
    return createCountJFreeChart(data, info);
}
Also used : TimeSeries(org.spf4j.tsdb2.TimeSeries)

Example 42 with TimeSeries

use of com.google.bigtable.repackaged.com.google.monitoring.v3.TimeSeries in project spf4j by zolyfarkas.

the class TimeSeriesDatabase method generateCharts.

/**
 * Quantized recorders will have min, max avg charts and distribution charts generated. Counting recorders will have
 * simple charts generated.
 *
 * @param startTimeMillis
 * @param endTimeMillis
 * @param width
 * @param height
 * @return
 * @throws IOException
 */
@JmxExport(value = "generateChartsInterval", description = "generate charts for all measurements in specified interval")
public List<String> generateCharts(final long startTimeMillis, final long endTimeMillis, final int width, final int height) throws IOException {
    try {
        this.flush();
        Collection<TSTable> columnsInfo = this.getTSTables();
        List<String> result = new ArrayList<>(16);
        for (TSTable info : columnsInfo) {
            TimeSeries data = this.read(info.getTableName(), startTimeMillis, endTimeMillis);
            if (data.getTimeStamps().length > 0) {
                if (canGenerateMinMaxAvgCount(info)) {
                    result.add(generateMinMaxAvgCountChart(info, data, width, height));
                }
                if (canGenerateHeatChart(info)) {
                    result.add(generateHeatChart(info, data, width, height));
                }
            }
        }
        Multimap<String, TSTable> counters = getCounters(columnsInfo);
        Map<String, Collection<TSTable>> asMap = counters.asMap();
        for (Map.Entry<String, Collection<TSTable>> entry : asMap.entrySet()) {
            Collection<TSTable> ltables = entry.getValue();
            int l = ltables.size();
            long[][] timestamps = new long[l][];
            double[][] cdata = new double[l][];
            double[][] cdata2 = new double[l][];
            int i = 0;
            String[] measurementNames = new String[cdata.length];
            String[] measurementNames2 = new String[cdata2.length];
            String uom1 = "count";
            String uom2 = "";
            for (TSTable colInfo : ltables) {
                TimeSeries data = this.read(colInfo.getTableName(), startTimeMillis, endTimeMillis);
                timestamps[i] = data.getTimeStamps();
                final long[][] values = data.getValues();
                cdata[i] = Arrays.getColumnAsDoubles(values, colInfo.getColumnIndex("count"));
                cdata2[i] = Arrays.getColumnAsDoubles(values, colInfo.getColumnIndex("total"));
                measurementNames[i] = colInfo.getTableName() + ".count";
                measurementNames2[i] = colInfo.getTableName() + ".total";
                uom2 = new String(colInfo.getTableMetaData(), StandardCharsets.UTF_8);
                i++;
            }
            result.add(generateCountChart(entry.getKey(), timestamps, measurementNames, measurementNames2, uom1, uom2, cdata, cdata2, width, height));
        }
        return result;
    } catch (IOException | RuntimeException ex) {
        throw ex;
    }
}
Also used : TimeSeries(org.spf4j.tsdb2.TimeSeries) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) TLongArrayList(gnu.trove.list.array.TLongArrayList) IOException(java.io.IOException) Collection(java.util.Collection) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) JmxExport(org.spf4j.jmx.JmxExport)

Example 43 with TimeSeries

use of com.google.bigtable.repackaged.com.google.monitoring.v3.TimeSeries in project spf4j by zolyfarkas.

the class TimeSeriesDatabase method createMinMaxAvgJFreeChart.

public JFreeChart createMinMaxAvgJFreeChart(final String tableName, final long startTime, final long endTime) throws IOException {
    TSTable info = this.getTSTable(tableName);
    TimeSeries data = this.read(tableName, startTime, endTime);
    return createMinMaxAvgJFreeChart(data, info);
}
Also used : TimeSeries(org.spf4j.tsdb2.TimeSeries)

Example 44 with TimeSeries

use of com.google.bigtable.repackaged.com.google.monitoring.v3.TimeSeries in project spring-cloud-gcp by GoogleCloudPlatform.

the class HealthTrackerImplTests method messagesOverThresholdNoProcessing.

@Test
public void messagesOverThresholdNoProcessing() throws InterruptedException {
    LockSupport.parkNanos(1001 * 1000000);
    ListTimeSeriesPagedResponse listTimeSeriesPagedResponse = mock(ListTimeSeriesPagedResponse.class);
    TimeSeries timeSeries = TimeSeries.newBuilder().addPoints(Point.newBuilder().setValue(TypedValue.newBuilder().setInt64Value(201).build()).build()).build();
    ListTimeSeriesResponse timeSeriesResponse = ListTimeSeriesResponse.newBuilder().addTimeSeries(timeSeries).build();
    ListTimeSeriesPage listTimeSeriesPage = mock(ListTimeSeriesPage.class);
    when(listTimeSeriesPagedResponse.getPage()).thenReturn(listTimeSeriesPage);
    when(listTimeSeriesPage.getResponse()).thenReturn(timeSeriesResponse);
    doReturn(listTimeSeriesPagedResponse).when(metricServiceClient).listTimeSeries(any(ProjectName.class), anyString(), any(), any());
    long messagesOverThreshold = healthTracker.messagesOverThreshold();
    assertThat(messagesOverThreshold).isEqualTo(1);
}
Also used : TimeSeries(com.google.monitoring.v3.TimeSeries) ProjectName(com.google.monitoring.v3.ProjectName) ListTimeSeriesPage(com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPage) ListTimeSeriesResponse(com.google.monitoring.v3.ListTimeSeriesResponse) ListTimeSeriesPagedResponse(com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse) Test(org.junit.Test)

Example 45 with TimeSeries

use of com.google.bigtable.repackaged.com.google.monitoring.v3.TimeSeries in project java-monitoring by googleapis.

the class MetricServiceClientTest method createServiceTimeSeriesTest2.

@Test
public void createServiceTimeSeriesTest2() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockMetricService.addResponse(expectedResponse);
    String name = "name3373707";
    List<TimeSeries> timeSeries = new ArrayList<>();
    client.createServiceTimeSeries(name, timeSeries);
    List<AbstractMessage> actualRequests = mockMetricService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateTimeSeriesRequest actualRequest = ((CreateTimeSeriesRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertEquals(timeSeries, actualRequest.getTimeSeriesList());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Empty(com.google.protobuf.Empty) TimeSeries(com.google.monitoring.v3.TimeSeries) AbstractMessage(com.google.protobuf.AbstractMessage) CreateTimeSeriesRequest(com.google.monitoring.v3.CreateTimeSeriesRequest) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

TimeSeries (com.google.monitoring.v3.TimeSeries)36 Test (org.junit.Test)23 ArrayList (java.util.ArrayList)18 ProjectName (com.google.monitoring.v3.ProjectName)17 TimeInterval (com.google.monitoring.v3.TimeInterval)14 ListTimeSeriesPagedResponse (com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse)11 CreateTimeSeriesRequest (com.google.monitoring.v3.CreateTimeSeriesRequest)11 TimeSeries (org.spf4j.tsdb2.TimeSeries)11 ListTimeSeriesRequest (com.google.monitoring.v3.ListTimeSeriesRequest)10 MetricServiceClient (com.google.cloud.monitoring.v3.MetricServiceClient)8 ListTimeSeriesResponse (com.google.monitoring.v3.ListTimeSeriesResponse)8 AbstractMessage (com.google.protobuf.AbstractMessage)8 Point (com.google.monitoring.v3.Point)6 MonitoredResource (com.google.api.MonitoredResource)5 Empty (com.google.protobuf.Empty)5 StatusRuntimeException (io.grpc.StatusRuntimeException)5 HashMap (java.util.HashMap)5 Metric (com.google.api.Metric)4 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)4 TypedValue (com.google.monitoring.v3.TypedValue)3