Giter Club home page Giter Club logo

kairosdb-client's Introduction

KairosDB Client

Build Status

The KairosDB client is a Java library that makes sending metrics and querying the KairosDB server simple. The HttpClient class is used to push metrics or query the KairosDB server. The library uses the builder pattern to simplify the task of creating the JSON that is used by the client. If an error occurs an UnexpectedResponseException is thrown which contains the HTTP response code.

Sending Metrics

Sending metrics is done by using the MetricBuilder. You simply add a metric, the tags associated with the metric, and the data points.

try(HttpClient client = new HttpClient("http://localhost:8080"))
{
	MetricBuilder builder = MetricBuilder.getInstance();
	builder.addMetric("metric1")
			.addTag("host", "server1")
			.addTag("customer", "Acme")
			.addDataPoint(System.currentTimeMillis(), 10)
			.addDataPoint(System.currentTimeMillis(), 30L);
	client.pushMetrics(builder);
}

Querying Data Points

Querying data points is similarly done by using the QueryBuilder class. A query requires a date range. The start date is required, but the end date defaults to NOW if not specified. The metric(s) that you are querying for is also required. Optionally, tags may be added to narrow down the search.

try(HttpClient client = new HttpClient("http://localhost:8080"))
{
	QueryBuilder builder = QueryBuilder.getInstance();
	builder.setStart(2, TimeUnit.MONTHS)
			.setEnd(1, TimeUnit.MONTHS)
			.addMetric("metric1")
			.addAggregator(AggregatorFactory
			.createAverageAggregator(5, TimeUnit.MINUTES));
	QueryResponse response = client.query(builder);
}

Querying Metric Tags

Querying metric tags is done by using the QueryTagBuilder class. A query requires a date range. The start date is required, but the end date defaults to NOW if not specified. The metric(s) that you are querying for is also required. Optionally, tags may be added to narrow down the search.

try(HttpClient client = new HttpClient("http://localhost:8080"))
{
	QueryTagBuilder builder = QueryTagBuilder.getInstance();
	builder.setStart(2, TimeUnit.MONTHS)
			.setEnd(1, TimeUnit.MONTHS)
			.addMetric("metric1");
	QueryTagResponse response = client.queryTags(builder);
}

Querying Metric Names

You can get a list of all metric names in KairosDB.

try(HttpClient client = new HttpClient("http://localhost:8080"))
{
	List<String> metricNames = client.getMetricNames();
	for (String metricName : metricNames)
	{
		System.out.println(metricName);
	}
}

Delete a Metric

You can delete a metric and all its data.

try(HttpClient client = new HttpClient("http://localhost:8080"))
{
	client.deleteMetric("myMetric");
}

Delete Data Points

Or delete a set of data point for a given metric.

try(HttpClient client = new HttpClient("http://localhost:8080"))
{
	QueryBuilder builder = QueryBuilder.getInstance();
	builder.setStart(2, TimeUnit.MONTHS)
			.setEnd(1, TimeUnit.MONTHS)
			.addMetric("metric1");
	client.delete(builder);
}

Check Server Health

You can check the server health by calling the getStatus() or getStatusCheck() methods. Status check returns 204 if healthy and 500 if not. The getStatus() method returns JSON with a list of checks and their status.

try(HttpClient client = new HttpClient("http://localhost:8080"))
{
	int statusCode = client.getStatusCheck();

	List<String> status = client.getStatus();
}

Get the version of KairosDB

You get get the version string for the server.

try(HttpClient client = new HttpClient("http://localhost:8080"))
{
	String version = client.getVersion();
}

Create Roll-up Task

You can create a roll-up task using the RollupBuilder.

try(HttpClient client = new HttpClient("http://localhost:8080"))
{
	RollupBuilder builder = RollupBuilder.getInstance("Metric1_rollupTask", new RelativeTime(1, TimeUnit.DAYS));
	Rollup rollup1 = builder.addRollup("metric1_rollup");
	QueryBuilder builder1 = rollup1.addQuery();
	builder1.setStart(1, TimeUnit.HOURS);
	builder1.addMetric("metric1")
			.addAggregator(AggregatorFactory.createMaxAggregator(1, TimeUnit.MINUTES));
	RollupTask rollupTask = client.createRollupTask(builder);
}

Get Roll-up Task

Or get a roll-up task

try(HttpClient client = new HttpClient("http://localhost:8080"))
{
	RollupTask rollupTask = client.getRollupTask("ddafbb87-3063-4013-8e98-da2ff8671caf");
}

Delete Roll-up task

Or delete a roll-up task

try(HttpClient client = new HttpClient("http://localhost:8080"))
{
	client.deleteRollupTask("ddafbb87-3063-4013-8e98-da2ff8671caf");
}

Custom Data Types

Starting with version 0.9.4 of KairosDB, you can store more than just numbers as values. This version of the client has been modified to support custom data types. Note that custom types is only supported by the HTTP client. The Telnet protocol for KairosDB does not support custom types.

Longs, doubles, and Strings are now supported by default. If, however, you want to store and query for other data types, additional work is required.

You must first understand the different custom type values you must specify on the client; group type and registered type. The group type is used for JSON serialization/de-serialization. The registered type is used by the server to identify which DataPointFactory it will use to serialize/de-serialize the data to the data store.

Next, you must modify KairosDB to handle the new data type.

Next, you must create an object for the new data type. This is simply a POJO that contains fields for the new type. For example, if you wanted to store complex numbers as your new data type you would create a ComplexNumber class. The client uses GSON to serialize/de-serialize this class.

public class ComplexNumber
{
    private double real;
    private double imaginary;

    public ComplexNumber(double real, double imaginary)
    {
        this.real = real;
        this.imaginary = imaginary;
    }
}

This Class must then be registered with the client by its group type. In this example, "complex" is the name of the group type registered in KairosDB. Then, when you add the metric you must specify the registered type. In this example, "complex-number" is the registered type in KairosDB.

try(HttpClient client = new HttpClient("http://localhost:8080"))
{
	client.registerCustomDataType("complex", ComplexNumber.class); // "complex" is the group type

	MetricBuilder metricBuilder = MetricBuilder.getInstance();
	Metric metric = metricBuilder.addMetric("metric1", "complex-number");  // "complex-number" is the registered type
	metric.addTag("host", "myHost");
	metric.addDataPoint(System.currentTimeMillis(), new ComplexNumber(2.3, 3.4));
	metric.addDataPoint(System.currentTimeMillis(), new ComplexNumber(1.1, 5));

	client.pushMetrics(metricBuilder);
}

Last, you must cast to your new type following a query for a metric.

try(HttpClient client = new HttpClient("http://localhost:8080"))
{
	QueryBuilder queryBuilder = QueryBuilder.getInstance();
	queryBuilder.addMetric("metric1");
	queryBuilder.setStart(1, TimeUnit.HOURS);

	QueryResponse response = client.query(queryBuilder);
	List<DataPoint> dataPoints = response.getQueries().get(0).getResults().get(0).getDataPoints();

	for (DataPoint dataPoint : dataPoints)
	{
		ComplexNumber complex = (ComplexNumber) dataPoint.getValue();
		System.out.println(complex.real + " + " + complex.imaginary + "i");
	}
}

KairosDB compatibility

Version 2.3.0 of the client was tested with KairosDB version 1.2.1-1.

Contributions

We want your contributions but please do pull requests on the develop branch and not the master.

Copyright and License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

kairosdb-client's People

Contributors

alemar avatar alexeysem-dataart avatar brianhks avatar codyaray avatar euforia avatar freakman avatar jsabin avatar robshep avatar spricoder avatar sspieker avatar vimal3271 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kairosdb-client's Issues

project doesnt seem to build on windows eclipse

Hi,
Am facing a few problems trying to run this in windows eclipse.

mvn package fails..
Running org.kairosdb.client.ClientIntegrationTest
java.io.IOException: Unable to delete file: build\h2db\kairosdb.h2.db
at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:2106)
at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:1583)
at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1465)
seems the same process holds lock on the file.

Even after taking all the jars from kairosdb/lib and taking http-client 4.3.3
i get following error..
Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.(DefaultHttpRequestWriterFactory.java:52)
...
at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:726)
at org.kairosdb.client.HttpClient.(HttpClient.java:50)

Can you please check?

Regards
Sanjay

Add support for Rollups API

As of now, the Kairosdb-Client is a bit incomplete because it provides no support for the management of Rollups. The company I am working for needs rollups to create preaggregated data, so I will need to write some classes for this. Do you also see this as a sensible extension for the kairosdb-client?

Runtime Exception, No-args constructor issue during Gson mapping

Hi,

I am getting a RuntimeException during queries, also for the most simple one like that:

QueryBuilder qb = QueryBuilder.getInstance();
qb.setStart(10, TimeUnit.HOURS).addMetric("kairosdb.http.ingest_time");
c.client.query(qb);

I am using the dev-branch version. I already tried out some other gson versions, but that didnt help.

Thanks a alot !

Exception in thread "main" java.lang.RuntimeException: No-args constructor for class org.kairosdb.client.response.ErrorResponse does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
at com.google.gson.MappedObjectConstructor.constructWithNoArgConstructor(MappedObjectConstructor.java:64)
.
.
.
at org.kairosdb.client.AbstractClient.query(AbstractClient.java:104)

Multi Query

I used each Querybuilder to get dataPoints on every metrics. I want one query to get several metrics.
Could I take it?

Query regarding HttpClient retry mechanism

HttpClient has a retry mechanism.

Can I ask why the internal retry counter is incremented on every call to execute

https://github.com/kairosdb/kairosdb-client/blob/master/src/main/java/org/kairosdb/client/HttpClient.java#L85

After testing the client last night - I see that after a few thousand successful requests, when the server (on my laptop) went away (died), there were delays of more than 40 minutes between "exceptions"

when the server recovered some time later requests were successful again, but when it went away again, the retry mechanism was still causing delays of more than an hour.

Why the ++operator at line 85?
is it meant for some kind of exponential backoff?
what if it were reset to the initial value after a successful "1st attempt" submission instead of successful submissions altering the internal state every time?

happy to provide a patch for any of this.

Irregular groups alignment

Hi,

When querying grouped series with non unitary sampling (eg: 2 minutes), some gapped groups returns some points that aren't aligned with ungapped groups timestamps.

Here's a query example:

{
  "metrics": [
    {
      "name": [
        "http.access.count"
      ],
      "aggregators": [
        {
          "name": "sum",
          "sampling": {
            "value": "2",
            "unit": "minutes"
          },
          "align_sampling": true
        }
      ],
      "group_by": [
        {
          "name": "tag",
          "tags": [
            "status_code"
          ]
        }
      ]
    }
  ],
  "cache_time": 0,
  "start_relative": {
    "value": "3",
    "unit": "hours"
  },
  "end_relative": {
    "value": "3",
    "unit": "minutes"
  }
}

This way, I'll get common HTTP codes like 200 that will be sampled every 2 minutes (generally on even ones), but some rare codes that aren't present on every minute will be sampled on the exact minute they appear, which is sometimes an odd minute, creating a timestamp that doesn't exist on full groups.

I thought using align_sampling should align different groups on the same timestamps but it seems not.

Using gaps aggregator doesn't help.

QueryResponse response = client.query(builder) produces unknown messages

When I run

"QueryResponse response = client.query(builder);" (without "")

in my Code, there is always a message dropped:

"******************* Type=number" (without "")

I think it it from GSON or Apache's Httpclient (bot inside kairosdb-client), but I can't turn it off and I don't know where it exactly comes from. I searched inside kairosdb-client, but found no point where a Message like this seems to be produced.

It is also not an error or warning.

Can you help me turn this mesage off?

Unable to push metrics using kairosdb client

Hi ,

While pushing metrics using metric builder , I am getting the below error :

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/HttpResponse
at com.kairosdb.KairosPushTest.main(KairosPushTest.java:24)
Caused by: java.lang.ClassNotFoundException: org.apache.http.HttpResponse
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more

I am using client version 2.2.0 .

Plugin Build Issue

Hi,

I had an issue building the client using maven with netbeans. In the pom.xml file, I first got an error telling me I needed a version with the maven-gpg-plugin. I added 1.5, but then got the following error: Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.5:sign. Tried with 1.4, but build stopped on passphrase.
I tried deleting the maven repository, but it had the same result. In the end to get a successful build I removed these lines from the pom.xml file completely:

org.apache.maven.plugins
maven-gpg-plugin
1.5


sign-artifacts
verify

sign



Is there a way to build without having to do this?
Regards,
MS

ArrayIndexOutOfBoundsException when re-using MetricBuilder in multiple threads

I reuse the same MetricBuilder to collect a batch/bulk of Metrics before sending them thru the wire but it failed with:

java.lang.ArrayIndexOutOfBoundsException: 887
        at java.util.ArrayList.add(ArrayList.java:463)
        at org.kairosdb.client.builder.MetricBuilder.addMetric(MetricBuilder.java:68)

So it seems MetricBuilder is not prepared to be used in multi-threaded environment.

Are there any recommendations how to do this ?
My application does monitoring.monitor("measurement", value, tags) all over the place. I don't want to make single HTTP call for all of them.

Upgrade Guava dependency to newer version

At the moment the client uses Guava v14.
The latest available release of Guava is v24.

Is there any problem to upgrade it ?
I know that Guava is not always easy to be upgraded due to its short deprecation cycles.

I can provide a PR if you think this is doable!

Api call to accomplish a call with tag with multitude of values

Hi,

How do I accomplish following quesry with the KairosDB client?
The part of creating a collection of AssetId is of interest with KairosDB client api.

{
"metrics": [
{
"tags": {
"AssetId": [
"23",
"27"
]
},
"name": "thermostat"
}
],
"cache_time": 0,
"start_absolute": 82800000
}
Kindly,
Markoolio

url for tagnames

The current code uses .../api/v1/tagNames which doesn't seem to exist. It should be .../api/v1/tagnames

Custom HttpClient support

Hi, I noticed that this client uses org.apache.http.client.HttpClient and provides a constructor taking an HttpClientBuilder as a parameter. But in my situation, I want one more constructor that takes an org.apache.http.client.HttpClient as a parameter, because my http client is created by another library and there's no way to get that kind of builder object. Currently I extends org.kairosdb.client.HttpClient and replace the inner client using org.kairosdb.client.HttpClient#setClient method which is intended to be a test method. I suppose this may be a common situation and wonder if there are any plans to support this. Thank you.

Upgrading supported Java version

Hi

Currently client supports Java6. Are there any limitations to bump this to min version Java7? Is anyone still using this client with Java6?

KairosDB server does not notify the client when Cassandra connection is down

Version: kairosdb_0.9.4-6
OS: Debian Wheezy 64bit

I used KairosDB with Cassandra database and I have a client which sends data to KairosDB server.
After stopping Cassandra(service is down), an error is received in KairosDB server, but the client is not notified that the send data could not be stored.

This behaviour cause data loss when the send data is deleted/dropped.

The issue can be reproduce by setting the configuration and sending some POST requests to the KairosDB server.

error when query with metric.addAggregator

here's may code to query:
QueryBuilder builder = QueryBuilder.getInstance();
builder.setStart(2, TimeUnit.HOURS)
.addMetric("metric1")
.addAggregator(AggregatorFactory.createMinAggregator(1, TimeUnit.MINUTES))

the response.getErrors() says:
[query.metric[0].aggregators[0].m_sampling may not be null]
It may be Sampling aggregators serialize issue.

add align parameters to aggregators

Since version 0.9.4 aggregators in Kairos have two more parameters: align sampling and align start time.

This was most likely implemented after this discussion: https://groups.google.com/forum/#!searchin/kairosdb-group/align$20time/kairosdb-group/yAMTV4uBPz8/_CAkd9xsok8J

And is also mentioned here: https://groups.google.com/d/msg/kairosdb-group/2WPuxh6FMTQ/joiEiPpZrTYJ
"Brian has added code in the RangeAggregator (see setAlignStartTime() and setAlignSampling()) to address these issues and provide more flexibility."

We need these two parameters in kairos-client. There is even a todo item on line 41 in Aggregator.java:
" // todo add align_sampling - aligns to the next biggest unit base on the unit"

Get 500 error adding metrics

I get a 500 error whenever I try to add a metric. I simplified my code to reproduce and inserted below:

    try {
        MetricBuilder builder = MetricBuilder.getInstance();
        Metric metric = builder.addMetric("Test");
        metric.addTag("Host", "localhost");
        metric.addDataPoint(System.currentTimeMillis(), 10L);

        System.out.println(builder.build());
        Response response = httpClient.pushMetrics(builder);    
        if (response.getStatusCode() != 200) {
            System.out.println(response.getErrors().toString());
            throw new Exception("Did not return 200");
        }
    } finally {
        httpClient.shutdown();
    }

The resulting JSON string is as follows:

[{"datapoints":[[1374407396775,10]],"name":"Test","dataPoints":[{"value":10,"integer":true,"timestamp":1374407396775}],"tags":{"Host":"localhost"}}]

The error message with the 500 errors is as follows:
[Expected a name but was BEGIN_ARRAY at line 1 column 65]

It appears that the build is using both the "timestamp" with "value" for a single data point and "datapoints" at the same time.

Allow user to set maximum connection per route

From my understanding, KairosDB Java Client uses Apache Http Client behind the scene. It's using default value of 2 in max connection per route. I have a multi-threaded application that shares the same KairosDB client instance, but I had to write a subclass to extend Kairos HttpClient so I can pass in a new Apache Http Client with a higher max connection count.

It would be nice if the max connection per route is configurable in the default client.

use client in springboot with @Async

When I use this in a springboot project with async, erros shows like:

java.lang.IllegalStateException: Connection pool shut down
	at org.apache.http.util.Asserts.check(Asserts.java:34) ~[httpcore-4.4.8.jar:4.4.8]
	at org.apache.http.pool.AbstractConnPool.lease(AbstractConnPool.java:191) ~[httpcore-4.4.8.jar:4.4.8]
	at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.requestConnection(PoolingHttpClientConnectionManager.java:257) ~[httpclient-4.5.3.jar:4.5.3]
	at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:176) ~[httpclient-4.5.3.jar:4.5.3]
	at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) ~[httpclient-4.5.3.jar:4.5.3]
	at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) ~[httpclient-4.5.3.jar:4.5.3]
	at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) ~[httpclient-4.5.3.jar:4.5.3]
	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) ~[httpclient-4.5.3.jar:4.5.3]
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) ~[httpclient-4.5.3.jar:4.5.3]
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) ~[httpclient-4.5.3.jar:4.5.3]
	at org.kairosdb.client.HttpClient.execute(HttpClient.java:107) ~[client-2.2.0.jar:na]
	at org.kairosdb.client.HttpClient.postData(HttpClient.java:76) ~[client-2.2.0.jar:na]
	at org.kairosdb.client.AbstractClient.pushMetrics(AbstractClient.java:87) ~[client-2.2.0.jar:na]

org.codehaus.jackson.map.annotate.JsonSerialize$Inclusion.NON_EMPTY (through reference chain: org.kairosdb.client.builder.QueryBuilder["metrics"]->java.util.ArrayList[0])

when i execute query with then kairos-client , i met a exception like this

Exception in thread "main" org.codehaus.jackson.map.JsonMappingException: org.codehaus.jackson.map.annotate.JsonSerialize$Inclusion.NON_EMPTY (through reference chain: org.kairosdb.client.builder.QueryBuilder["metrics"]->java.util.ArrayList[0])
at org.codehaus.jackson.map.JsonMappingException.wrapWithPath(JsonMappingException.java:215)
at org.codehaus.jackson.map.JsonMappingException.wrapWithPath(JsonMappingException.java:194)
at org.codehaus.jackson.map.ser.SerializerBase.wrapAndThrow(SerializerBase.java:154)
at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:278)
at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:229)
at org.codehaus.jackson.map.ser.ContainerSerializers$AsArraySerializer.serialize(ContainerSerializers.java:130)
at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:428)
at org.codehaus.jackson.map.ser.BeanSerializer.serializeFields(BeanSerializer.java:244)
at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:211)
at org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:586)
at org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.java:244)
at org.codehaus.jackson.map.ObjectMapper._configAndWriteValue(ObjectMapper.java:1990)
at org.codehaus.jackson.map.ObjectMapper.writeValue(ObjectMapper.java:1576)
at org.kairosdb.client.builder.QueryBuilder.build(QueryBuilder.java:234)
at org.kairosdb.client.AbstractClient.query(AbstractClient.java:82)
at Get.main(Get.java:42)
Caused by: java.lang.EnumConstantNotPresentException: org.codehaus.jackson.map.annotate.JsonSerialize$Inclusion.NON_EMPTY
at sun.reflect.annotation.EnumConstantNotPresentExceptionProxy.generateException(EnumConstantNotPresentExceptionProxy.java:47)
at sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:75)
at sun.proxy.$Proxy6.include(Unknown Source)
at org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector.findSerializationInclusion(JacksonAnnotationIntrospector.java:289)
at org.codehaus.jackson.map.ser.PropertyBuilder.buildWriter(PropertyBuilder.java:108)
at org.codehaus.jackson.map.ser.BeanSerializerFactory._constructWriter(BeanSerializerFactory.java:727)
at org.codehaus.jackson.map.ser.BeanSerializerFactory.findBeanProperties(BeanSerializerFactory.java:536)
at org.codehaus.jackson.map.ser.BeanSerializerFactory.constructBeanSerializer(BeanSerializerFactory.java:375)
at org.codehaus.jackson.map.ser.BeanSerializerFactory.findBeanSerializer(BeanSerializerFactory.java:291)
at org.codehaus.jackson.map.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:241)
at org.codehaus.jackson.map.ser.StdSerializerProvider._createUntypedSerializer(StdSerializerProvider.java:747)
at org.codehaus.jackson.map.ser.StdSerializerProvider._createAndCacheUntypedSerializer(StdSerializerProvider.java:688)
at org.codehaus.jackson.map.ser.StdSerializerProvider.findValueSerializer(StdSerializerProvider.java:363)
at org.codehaus.jackson.map.ser.impl.PropertySerializerMap.findAndAddSerializer(PropertySerializerMap.java:39)
at org.codehaus.jackson.map.ser.ContainerSerializers$AsArraySerializer._findAndAddDynamic(ContainerSerializers.java:209)
at org.codehaus.jackson.map.ser.ContainerSerializers$IndexedListSerializer.serializeContents(ContainerSerializers.java:271)
... 12 more

the execute code like this

QueryBuilder builder = QueryBuilder.getInstance();
builder.setStart(Calendar.getInstance().getTime()).addMetric("kairosdb.jvm.free_memory");
HttpClient client = new HttpClient("10.11.0.9", 8015);
QueryResponse response = client.query(builder);
System.out.println("Response Code =" + response.getStatusCode());

    client.shutdown();

Could not get datapoints in query response

Here is the sample query code
builder.setStart(2, TimeUnit.HOURS)
.setEnd(new Date())
.addMetric("kairosdb.datastore.query_time")
.addAggregator(AggregatorFactory.createSumAggregator(2, TimeUnit.HOURS));
QueryResponse response = client.query(builder);

Response From Client:
response.getQueries().get(0).getResults().get(0).getDataPoints() gives 0 values

Response From Browser:
{"queries":[{"sample_size":6,"results":[{"name":"kairosdb.datastore.query_time","values":[[1432131822647,12],[1432132493439,177]]}]}]}

Query metric tags is not implemented for HBase

when i execute query use the kairosdb-client, i encounter a werid problem what is the

org.kairosdb.core.exception.DatastoreException: Query metric tags is not implemented for HBase
at net.opentsdb.kairosdb.HBaseDatastore.queryMetricTags(HBaseDatastore.java:151) ~[hbase_datastore-1.1.0_5.jar:na]
at org.kairosdb.core.datastore.KairosDatastore.queryTags(KairosDatastore.java:196) ~[kairosdb.jar:0.9.2.20131127180758]
at org.kairosdb.core.http.rest.MetricsResource.getMeta(MetricsResource.java:205) ~[kairosdb.jar:0.9.2.20131127180758]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_37]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_37]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_37]
at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_37]
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1480) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1411) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1360) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1350) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416) [jersey-servlet-1.15.jar:1.15]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538) [jersey-servlet-1.15.jar:1.15]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716) [jersey-servlet-1.15.jar:1.15]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) [javax.servlet-3.0.0.v201112011016.jar:na]
at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:263) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:178) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:91) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:62) [guice-servlet-3.0.jar:na]
at org.kairosdb.core.http.LoggingFilter.doFilter(LoggingFilter.java:48) [kairosdb.jar:0.9.2.20131127180758]
at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58) [guice-servlet-3.0.jar:na]
at org.kairosdb.core.http.MonitorFilter.doFilter(MonitorFilter.java:69) [kairosdb.jar:0.9.2.20131127180758]
at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113) [guice-servlet-3.0.jar:na]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307) [jetty-servlet-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453) [jetty-servlet-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382) [jetty-servlet-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.Server.handle(Server.java:365) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:937) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856) [jetty-http-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240) [jetty-http-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628) [jetty-io-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52) [jetty-io-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) [jetty-util-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) [jetty-util-8.1.8.v20121106.jar:8.1.8.v20121106]
at java.lang.Thread.run(Thread.java:662) [na:1.6.0_37]
11-27|20:26:14.202 [qtp957250718-171] ERROR [MetricsResource.java:253] - Query failed.
org.kairosdb.core.exception.DatastoreException: Query metric tags is not implemented for HBase
at net.opentsdb.kairosdb.HBaseDatastore.queryMetricTags(HBaseDatastore.java:151) ~[hbase_datastore-1.1.0_5.jar:na]
at org.kairosdb.core.datastore.KairosDatastore.queryTags(KairosDatastore.java:196) ~[kairosdb.jar:0.9.2.20131127180758]
at org.kairosdb.core.http.rest.MetricsResource.getMeta(MetricsResource.java:205) ~[kairosdb.jar:0.9.2.20131127180758]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_37]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_37]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_37]
at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_37]
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1480) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1411) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1360) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1350) [jersey-server-1.15.jar:1.15]
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416) [jersey-servlet-1.15.jar:1.15]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538) [jersey-servlet-1.15.jar:1.15]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716) [jersey-servlet-1.15.jar:1.15]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) [javax.servlet-3.0.0.v201112011016.jar:na]
at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:263) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:178) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:91) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:62) [guice-servlet-3.0.jar:na]
at org.kairosdb.core.http.LoggingFilter.doFilter(LoggingFilter.java:48) [kairosdb.jar:0.9.2.20131127180758]
at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58) [guice-servlet-3.0.jar:na]
at org.kairosdb.core.http.MonitorFilter.doFilter(MonitorFilter.java:69) [kairosdb.jar:0.9.2.20131127180758]
at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113) [guice-servlet-3.0.jar:na]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307) [jetty-servlet-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453) [jetty-servlet-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382) [jetty-servlet-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.Server.handle(Server.java:365) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:937) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856) [jetty-http-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240) [jetty-http-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) [jetty-server-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628) [jetty-io-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52) [jetty-io-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) [jetty-util-8.1.8.v20121106.jar:8.1.8.v20121106]
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) [jetty-util-8.1.8.v20121106.jar:8.1.8.v20121106]
at java.lang.Thread.run(Thread.java:662) [na:1.6.0_37]

Could u help me slove it ?thx

duration in setStart should be long type

When quering for DataPoints, it should be possible to enter long value for TimeUnit.MILLISECONDS. For example, last query has timestamp=1413537893570, and next query will be System.currentTimeMillis()-timestamp. Integer.MAX_VALUE is sometimes too small, and changing units to SECONDS/HOURS is not precise enough.

HTTPS client

Any plans to implement HTTPS client? Using my own httpClient with proper ssl context is impossible (expect for setClient method which is only for testing).

NullPointerException when creating a DataGapsMarkingAggregator

I am trying to create a DataGapsMarkingAggregator from a java test, and it throws a NullPointerException when trying to deserialize the response.

As some of the values will return null, and that is exactly what I want, JsonMapper throws a NullPointerException

mapper.fromJson(json, typeOfT);

I debugged the code and the method getBody(stream); is returning the data correctly. Then it throws the exception inside Class QueryResponse, Line 75,

KairosQueryResponse response = mapper.fromJson(body, KairosQueryResponse.class);

I am using KairosDb-Client version 2.1.1
Furthermore, Is there a way to tell kairos explicitly to ignore null values or what should I do?

Thank you!

It is the bug when I push the string "127.0.0.1"

this is my code
`MetricBuilder builder = MetricBuilder.getInstance();

builder.addMetric("metric1")
.addTag("host", "server1")
.addTag("customer", "Acme")
.addDataPoint(System.currentTimeMillis(), "127.0.0.1");
HttpClient client = new HttpClient("http://localhost:8080");
Response response = client.pushMetrics(builder);
client.shutdown();`

I run the code but I got errors: multiple points
I think it is the bug.Any help is appreciated.

Build failure

Hi,

I am using the JDK 1.7.0_51 to build the Kairos client and the build fails on the class InMemoryKairosServer under the tests. There are some imports not used that are causing the build to fail (in particular the sun.security.pkcs11.Secmod class is not resolved in my JDK). Removing the imports everything goes well.

Create a way to get response JSON from a query.

What is the optimal way of querying for datapoints from a java client? Currently I get the datapoints using the following i.e, get a list of datapoints and then iterate through it to append the json. Is there a way that I can get the entire json response at a time instead of me having to iterate through the list and append? I know that I can get the entire json reponse using rest call. But, I want to know if there is a way to do it from Java client.

NullPointerException in AbstractClient

    at org.kairosdb.client.AbstractClient.getResponse(AbstractClient.java:177)
    at org.kairosdb.client.AbstractClient.pushMetrics(AbstractClient.java:132)

I guess the server is either returning malformed JSON or just does not include "errors" there.
Cannot tell because the actual response is not logged.
Also have no idea how to reproduce as it happens from time to time only.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.