Initial Commit

This commit is contained in:
mckang
2018-09-07 13:37:56 +09:00
parent 5e3bcf4b4b
commit 2b48c2004e
52 changed files with 727 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.classpath
.project

View File

@ -0,0 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8

View File

@ -0,0 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5

View File

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

30
promql_client/pom.xml Normal file
View File

@ -0,0 +1,30 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bdwise.prometheus.client</groupId>
<artifactId>promql_client</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>promql_client</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.1</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,51 @@
package com.bdwise.prometheus.client.builder;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
public class InstantQueryBuilder implements QueryBuilder {
private static final String TARGET_URI_PATTERN_SUFFIX = "/api/v1/query?query=#{query}&time=#{time}&timeout=#{timeout}";
private static final String TIME_EPOCH_TIME = "time";
private static final String TIMEOUT = "timeout";
private static final String QUERY_STRING = "query";
private String targetUriPattern;
private Map<String, Object> params = new HashMap<String, Object>();
public InstantQueryBuilder(String serverUrl) {
targetUriPattern = serverUrl+ TARGET_URI_PATTERN_SUFFIX;
params.put(TIMEOUT, "");
params.put(TIME_EPOCH_TIME, "");
}
public InstantQueryBuilder withQuery(String query) {
params.put(QUERY_STRING, query);
return this;
}
public InstantQueryBuilder withEpochTime(long time) {
params.put(TIME_EPOCH_TIME, time);
return this;
}
public InstantQueryBuilder withTimeout(String timeout) {
params.put(TIMEOUT, timeout);
return this;
}
public URI build() {
return URI.create(Utils.namedFormat(targetUriPattern, params));
}
private boolean validate() {
return true;
}
}

View File

@ -0,0 +1,5 @@
package com.bdwise.prometheus.client.builder;
public interface QueryBuilder {
}

View File

@ -0,0 +1,44 @@
package com.bdwise.prometheus.client.builder;
public enum QueryBuilderType {
RangeQuery{
@SuppressWarnings("unchecked")
@Override
public RangeQueryBuilder newInstance(String prometheusUrl) {
return new RangeQueryBuilder(prometheusUrl);
}
},
InstantQuery{
@SuppressWarnings("unchecked")
@Override
public InstantQueryBuilder newInstance(String prometheusUrl) {
return new InstantQueryBuilder(prometheusUrl);
}
},
MetadaQuery{
@SuppressWarnings("unchecked")
@Override
public QueryBuilder newInstance(String prometheusUrl) {
// TODO Auto-generated method stub
return null;
}
},
TargetQuery{
@SuppressWarnings("unchecked")
@Override
public QueryBuilder newInstance(String prometheusUrl) {
// TODO Auto-generated method stub
return null;
}
};
public abstract <T extends QueryBuilder> T newInstance(String prometheusUrl);
}

View File

@ -0,0 +1,54 @@
package com.bdwise.prometheus.client.builder;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
public class RangeQueryBuilder implements QueryBuilder {
private static final String TARGET_URI_PATTERN_SUFFIX = "/api/v1/query_range?query=#{query}&start=#{start}&end=#{end}&step=#{step}";
private static final String START_TIME_EPOCH_TIME = "start";
private static final String END_TIME_EPOCH_TIME = "end";
private static final String STEP_TIME = "step";
private static final String QUERY_STRING = "query";
private String targetUriPattern;
private Map<String, Object> params = new HashMap<String, Object>();
public RangeQueryBuilder(String serverUrl) {
targetUriPattern = serverUrl+ TARGET_URI_PATTERN_SUFFIX;
}
public RangeQueryBuilder withQuery(String query) {
params.put(QUERY_STRING, query);
return this;
}
public RangeQueryBuilder withStartEpochTime(long startTime) {
params.put(START_TIME_EPOCH_TIME, startTime);
return this;
}
public RangeQueryBuilder withEndEpochTime(long endTime) {
params.put(END_TIME_EPOCH_TIME, endTime);
return this;
}
public RangeQueryBuilder withStepTime(String step) {
params.put(STEP_TIME, step);
return this;
}
public URI build() {
return URI.create(Utils.namedFormat(targetUriPattern, params));
}
private boolean validate() {
return true;
}
}

View File

@ -0,0 +1,25 @@
package com.bdwise.prometheus.client.builder;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Utils {
private final static Pattern namedFormatPattern = Pattern.compile("#\\{(?<key>.*?)}");
public static String namedFormat(final String format, Map<String, ? extends Object> kvs) {
final StringBuffer buffer = new StringBuffer();
final Matcher match = namedFormatPattern.matcher(format);
while (match.find()) {
final String key = match.group("key");
final Object value = kvs.get(key);
if (value != null)
match.appendReplacement(buffer, value.toString());
else if (kvs.containsKey(key))
match.appendReplacement(buffer, "null");
else
match.appendReplacement(buffer, "");
}
match.appendTail(buffer);
return buffer.toString();
}
}

View File

@ -0,0 +1,70 @@
package com.bdwise.prometheus.client.converter;
import java.io.IOException;
import com.bdwise.prometheus.client.converter.query.DefaultQueryResult;
import com.bdwise.prometheus.client.converter.query.QueryDataType;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
public abstract class ConvertUtil {
private static QueryDataType searchDataType(String typeString) {
for (QueryDataType each : QueryDataType.class.getEnumConstants()) {
if (each.name().compareToIgnoreCase(typeString) == 0) {
return each;
}
}
return null;
}
@SuppressWarnings("unchecked")
public static <T extends Data> DefaultQueryResult<T> convertQueryResultString(String jsonString) {
Gson gson = new GsonBuilder().registerTypeAdapter(DefaultQueryResult.class, new TypeAdapter<DefaultQueryResult<T>>() {
@Override
public DefaultQueryResult<T> read(JsonReader reader) throws IOException {
DefaultQueryResult<T> queryResult = new DefaultQueryResult<T>();
String status = null;
String resultType = null;
reader.beginObject();
while(reader.hasNext()) {
String propertyName = reader.nextName();
if("status".equals(propertyName)) {
status = reader.nextString();
} else if("data".equals(propertyName)) {
reader.beginObject();
while(reader.hasNext()) {
propertyName = reader.nextName();
if("resultType".equals(propertyName)) {
resultType = reader.nextString();
} else if("result".equals(propertyName)) {
System.out.println("resultType:"+ resultType);
reader.beginArray();
while(reader.hasNext()) {
queryResult.addData((T) searchDataType(resultType).convert(reader));
}
reader.endArray();
}
}
reader.endObject();
}
}
reader.endObject();
queryResult.setStatus(status);
queryResult.setResultType(resultType);
return queryResult;
}
@Override
public void write(JsonWriter arg0, DefaultQueryResult<T> arg1) throws IOException {
}
}).create();
return gson.fromJson(jsonString, DefaultQueryResult.class);
}
}

View File

@ -0,0 +1,5 @@
package com.bdwise.prometheus.client.converter;
public interface Data {
}

View File

@ -0,0 +1,22 @@
package com.bdwise.prometheus.client.converter;
import java.util.List;
public abstract class Result<T extends Data>{
String status = null;
String resultType = null;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getResultType() {
return resultType;
}
public void setResultType(String resultType) {
this.resultType = resultType;
}
public abstract List<T> getResult();
}

View File

@ -0,0 +1,24 @@
package com.bdwise.prometheus.client.converter.query;
import java.util.ArrayList;
import java.util.List;
import com.bdwise.prometheus.client.converter.Data;
import com.bdwise.prometheus.client.converter.Result;
public class DefaultQueryResult<T extends Data> extends Result<T>{
List<T> result = new ArrayList<T>();
public void addData(T data) {
result.add(data);
}
@Override
public List<T> getResult() {
return result;
}
}

View File

@ -0,0 +1,72 @@
package com.bdwise.prometheus.client.converter.query;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.bdwise.prometheus.client.converter.Data;
public class MatrixData implements Data {
private Map<String,String> metric = new HashMap<String,String>();
private QueryResultItemValue[] dataValues;
public Map<String, String> getMetric() {
return metric;
}
public void setMetric(Map<String, String> metric) {
this.metric = metric;
}
public QueryResultItemValue[] getDataValues() {
return dataValues;
}
public void setDataValues(QueryResultItemValue[] values) {
this.dataValues = values;
}
public double[] getValues() {
double[] values = new double[dataValues.length];
int index = 0;
for(QueryResultItemValue dataValue : dataValues) {
values[index++] = dataValue.getValue();
}
return values;
}
public double[] getTimestamps() {
double[] timestamps = new double[dataValues.length];
int index = 0;
for(QueryResultItemValue dataValue : dataValues) {
timestamps[index++] = dataValue.getTimestamp();
}
return timestamps;
}
public String[] getFormattedTimestamps(String format) {
SimpleDateFormat formatter = new SimpleDateFormat(format);
String[] timestamps = new String[dataValues.length];
int index = 0;
for(QueryResultItemValue dataValue : dataValues) {
timestamps[index++] = formatter.format(new Date(Math.round(dataValue.getTimestamp()*1000L)));
}
return timestamps;
}
@Override
public String toString() {
return "MatrixData [metric=" + metric + ", dataValues=" + Arrays.toString(dataValues) + "]";
}
}

View File

@ -0,0 +1,86 @@
package com.bdwise.prometheus.client.converter.query;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import com.bdwise.prometheus.client.converter.Data;
import com.google.gson.stream.JsonReader;
public enum QueryDataType {
Matrix{
@SuppressWarnings("unchecked")
@Override
public MatrixData convert(JsonReader reader) throws IOException {
MatrixData resultDataItem = new MatrixData();
reader.beginObject();
while(reader.hasNext()) {
String name = reader.nextName();
if("metric".equalsIgnoreCase(name)) {
Map<String,String> metric = new HashMap<String,String>();
reader.beginObject();
while(reader.hasNext()) {
metric.put(reader.nextName(), reader.nextString());
}
reader.endObject();
resultDataItem.setMetric(metric);
} else if("values".equalsIgnoreCase(name)) {
ArrayList<QueryResultItemValue> resultDataItemValue = new ArrayList<QueryResultItemValue>();
reader.beginArray();
while(reader.hasNext()) {
reader.beginArray();
resultDataItemValue.add(new QueryResultItemValue(reader.nextDouble(), reader.nextDouble()));
reader.endArray();
}
reader.endArray();
resultDataItem.setDataValues(resultDataItemValue.toArray(new QueryResultItemValue[] {}));
}
}
reader.endObject();
return resultDataItem;
}
},
Vector{
@SuppressWarnings("unchecked")
@Override
public VectorData convert(JsonReader reader) throws IOException {
VectorData resultDataItem = new VectorData();
reader.beginObject();
while(reader.hasNext()) {
String name = reader.nextName();
if("metric".equalsIgnoreCase(name)) {
Map<String,String> metric = new HashMap<String,String>();
reader.beginObject();
while(reader.hasNext()) {
metric.put(reader.nextName(), reader.nextString());
}
reader.endObject();
resultDataItem.setMetric(metric);
} else if("value".equalsIgnoreCase(name)) {
reader.beginArray();
resultDataItem.setDataValue(new QueryResultItemValue(reader.nextDouble(), reader.nextDouble()));
reader.endArray();
}
}
reader.endObject();
return resultDataItem;
}
},
Scalar{
@SuppressWarnings("unchecked")
@Override
public ScalarData convert(JsonReader reader) throws IOException {
ScalarData resultDataItem = null;
resultDataItem = new ScalarData(reader.nextDouble(), reader.nextDouble());
return resultDataItem;
}
};
public abstract <T extends Data> T convert(JsonReader reader) throws IOException ;
}

View File

@ -0,0 +1,28 @@
package com.bdwise.prometheus.client.converter.query;
public class QueryResultItemValue {
private double timestamp;
private double value;
public QueryResultItemValue(double timestamp, double value) {
super();
this.timestamp = timestamp;
this.value = value;
}
public double getTimestamp() {
return timestamp;
}
public void setTimestamp(double timestamp) {
this.timestamp = timestamp;
}
public double getValue() {
return value;
}
public void setValue(double value) {
this.value = value;
}
@Override
public String toString() {
return "ResultDataItemValue [timestamp=" + timestamp + ", value=" + value + "]";
}
}

View File

@ -0,0 +1,11 @@
package com.bdwise.prometheus.client.converter.query;
import com.bdwise.prometheus.client.converter.Data;
public class ScalarData extends QueryResultItemValue implements Data {
public ScalarData(double timestamp, double value) {
super(timestamp, value);
}
}

View File

@ -0,0 +1,54 @@
package com.bdwise.prometheus.client.converter.query;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.bdwise.prometheus.client.converter.Data;
public class VectorData implements Data {
private Map<String,String> metric = new HashMap<String,String>();
private QueryResultItemValue dataValue;
public Map<String, String> getMetric() {
return metric;
}
public void setMetric(Map<String, String> metric) {
this.metric = metric;
}
public QueryResultItemValue getDataValue() {
return dataValue;
}
public void setDataValue(QueryResultItemValue value) {
this.dataValue = value;
}
public double getValue() {
return dataValue.getValue();
}
public double getTimestamps() {
return dataValue.getTimestamp();
}
public String getFormattedTimestamps(String format) {
SimpleDateFormat formatter = new SimpleDateFormat(format);
return formatter.format(new Date(Math.round(dataValue.getTimestamp()*1000)));
}
@Override
public String toString() {
return "VectorData [metric=" + metric + ", dataValue=" + dataValue + "]";
}
}

View File

@ -0,0 +1,27 @@
package com.bdwise.prometheus.client.builder;
import java.net.MalformedURLException;
import java.net.URI;
import junit.framework.TestCase;
public class UriBuilderTest extends TestCase {
public void testRangeQueryBuilder() throws MalformedURLException {
RangeQueryBuilder rangeQueryBuilder = QueryBuilderType.RangeQuery.newInstance("http://52.192.4.59:30900");
URI targetUri = rangeQueryBuilder.withQuery("irate(received_api_call_total[60s])")
.withStartEpochTime(System.currentTimeMillis() / 1000 - 60*10)
.withEndEpochTime(System.currentTimeMillis() / 1000)
.withStepTime("60s")
.build();
System.out.println(targetUri.toURL().toString());
}
public void testInstantQueryBuilder() throws MalformedURLException {
InstantQueryBuilder iqb = QueryBuilderType.InstantQuery.newInstance("http://52.192.4.59:30900");
URI targetUri = iqb.withQuery("irate(received_api_call_total[60s])").build();
System.out.println(targetUri.toURL().toString());
}
}

View File

@ -0,0 +1,22 @@
package com.bdwise.prometheus.client.comverter.query;
import com.bdwise.prometheus.client.converter.ConvertUtil;
import com.bdwise.prometheus.client.converter.Data;
import com.bdwise.prometheus.client.converter.query.DefaultQueryResult;
import com.bdwise.prometheus.client.converter.query.ScalarData;
import junit.framework.TestCase;
public class MatrixResultTest extends TestCase {
private String testScalarData="{\"status\":\"success\",\"data\":{\"resultType\":\"scalar\",\"result\":[1536200364.286,\"1\"]}}";
public void testParser() {
DefaultQueryResult<ScalarData> result = ConvertUtil.convertQueryResultString(testScalarData);
System.out.println("-----" +result.getResult().size());
for(Data data : result.getResult()) {
System.out.println("=======>" + data);
}
}
}

View File

@ -0,0 +1,20 @@
package com.bdwise.prometheus.client.comverter.query;
import com.bdwise.prometheus.client.converter.ConvertUtil;
import com.bdwise.prometheus.client.converter.Data;
import com.bdwise.prometheus.client.converter.query.DefaultQueryResult;
import com.bdwise.prometheus.client.converter.query.VectorData;
import junit.framework.TestCase;
public class ScalarResultTest extends TestCase {
private String testVectorData="{\"status\":\"success\",\"data\":{\"resultType\":\"vector\",\"result\":[{\"metric\":{\"POD\":\"person-application-1.5-5dcc65c754-7ztnz\",\"application\":\"person-1.5\\t\\t\\t\\t\\t\\t\\t\\t\",\"controller\":\"*\",\"endpoint\":\"http\",\"instance\":\"10.244.4.4:19000\",\"job\":\"person-application-1-5\",\"namespace\":\"default\",\"pod\":\"person-application-1.5-5dcc65c754-7ztnz\",\"service\":\"person-application-1-5\",\"url\":\"*\"},\"value\":[1536200364.286,\"0\"]},{\"metric\":{\"POD\":\"person-application-1.5-5dcc65c754-7ztnz\",\"application\":\"person-1.5\\t\\t\\t\\t\\t\\t\\t\\t\",\"controller\":\"com.satish.monitoring.web.rest.PersonResource\",\"endpoint\":\"http\",\"instance\":\"10.244.4.4:19000\",\"job\":\"person-application-1-5\",\"namespace\":\"default\",\"pod\":\"person-application-1.5-5dcc65c754-7ztnz\",\"service\":\"person-application-1-5\",\"url\":\"[GET]/person\"},\"value\":[1536200364.286,\"0\"]},{\"metric\":{\"POD\":\"person-application-1.5-5dcc65c754-8gb82\",\"application\":\"person-1.5\\t\\t\\t\\t\\t\\t\\t\\t\",\"controller\":\"*\",\"endpoint\":\"http\",\"instance\":\"10.244.2.4:19000\",\"job\":\"person-application-1-5\",\"namespace\":\"default\",\"pod\":\"person-application-1.5-5dcc65c754-8gb82\",\"service\":\"person-application-1-5\",\"url\":\"*\"},\"value\":[1536200364.286,\"0\"]},{\"metric\":{\"POD\":\"person-application-1.5-5dcc65c754-8gb82\",\"application\":\"person-1.5\\t\\t\\t\\t\\t\\t\\t\\t\",\"controller\":\"com.satish.monitoring.web.rest.PersonResource\",\"endpoint\":\"http\",\"instance\":\"10.244.2.4:19000\",\"job\":\"person-application-1-5\",\"namespace\":\"default\",\"pod\":\"person-application-1.5-5dcc65c754-8gb82\",\"service\":\"person-application-1-5\",\"url\":\"[GET]/person\"},\"value\":[1536200364.286,\"0\"]},{\"metric\":{\"POD\":\"person-application-1.5-5dcc65c754-8xh22\",\"application\":\"person-1.5\\t\\t\\t\\t\\t\\t\\t\\t\",\"controller\":\"*\",\"endpoint\":\"http\",\"instance\":\"10.244.1.4:19000\",\"job\":\"person-application-1-5\",\"namespace\":\"default\",\"pod\":\"person-application-1.5-5dcc65c754-8xh22\",\"service\":\"person-application-1-5\",\"url\":\"*\"},\"value\":[1536200364.286,\"0\"]},{\"metric\":{\"POD\":\"person-application-1.5-5dcc65c754-8xh22\",\"application\":\"person-1.5\\t\\t\\t\\t\\t\\t\\t\\t\",\"controller\":\"com.satish.monitoring.web.rest.PersonResource\",\"endpoint\":\"http\",\"instance\":\"10.244.1.4:19000\",\"job\":\"person-application-1-5\",\"namespace\":\"default\",\"pod\":\"person-application-1.5-5dcc65c754-8xh22\",\"service\":\"person-application-1-5\",\"url\":\"[GET]/person\"},\"value\":[1536200364.286,\"0\"]}]}}";
public void testParser() {
DefaultQueryResult<VectorData> result = ConvertUtil.convertQueryResultString(testVectorData);
System.out.println("-----" +result.getResult().size());
for(Data data : result.getResult()) {
System.out.println("=======>" + data);
}
}
}

View File

@ -0,0 +1,20 @@
package com.bdwise.prometheus.client.comverter.query;
import com.bdwise.prometheus.client.converter.ConvertUtil;
import com.bdwise.prometheus.client.converter.Data;
import com.bdwise.prometheus.client.converter.query.DefaultQueryResult;
import com.bdwise.prometheus.client.converter.query.VectorData;
import junit.framework.TestCase;
public class VectorResultTest extends TestCase {
private String testVectorData="{\"status\":\"success\",\"data\":{\"resultType\":\"vector\",\"result\":[{\"metric\":{\"POD\":\"person-application-1.5-5dcc65c754-7ztnz\",\"application\":\"person-1.5\\t\\t\\t\\t\\t\\t\\t\\t\",\"controller\":\"*\",\"endpoint\":\"http\",\"instance\":\"10.244.4.4:19000\",\"job\":\"person-application-1-5\",\"namespace\":\"default\",\"pod\":\"person-application-1.5-5dcc65c754-7ztnz\",\"service\":\"person-application-1-5\",\"url\":\"*\"},\"value\":[1536200364.286,\"0\"]},{\"metric\":{\"POD\":\"person-application-1.5-5dcc65c754-7ztnz\",\"application\":\"person-1.5\\t\\t\\t\\t\\t\\t\\t\\t\",\"controller\":\"com.satish.monitoring.web.rest.PersonResource\",\"endpoint\":\"http\",\"instance\":\"10.244.4.4:19000\",\"job\":\"person-application-1-5\",\"namespace\":\"default\",\"pod\":\"person-application-1.5-5dcc65c754-7ztnz\",\"service\":\"person-application-1-5\",\"url\":\"[GET]/person\"},\"value\":[1536200364.286,\"0\"]},{\"metric\":{\"POD\":\"person-application-1.5-5dcc65c754-8gb82\",\"application\":\"person-1.5\\t\\t\\t\\t\\t\\t\\t\\t\",\"controller\":\"*\",\"endpoint\":\"http\",\"instance\":\"10.244.2.4:19000\",\"job\":\"person-application-1-5\",\"namespace\":\"default\",\"pod\":\"person-application-1.5-5dcc65c754-8gb82\",\"service\":\"person-application-1-5\",\"url\":\"*\"},\"value\":[1536200364.286,\"0\"]},{\"metric\":{\"POD\":\"person-application-1.5-5dcc65c754-8gb82\",\"application\":\"person-1.5\\t\\t\\t\\t\\t\\t\\t\\t\",\"controller\":\"com.satish.monitoring.web.rest.PersonResource\",\"endpoint\":\"http\",\"instance\":\"10.244.2.4:19000\",\"job\":\"person-application-1-5\",\"namespace\":\"default\",\"pod\":\"person-application-1.5-5dcc65c754-8gb82\",\"service\":\"person-application-1-5\",\"url\":\"[GET]/person\"},\"value\":[1536200364.286,\"0\"]},{\"metric\":{\"POD\":\"person-application-1.5-5dcc65c754-8xh22\",\"application\":\"person-1.5\\t\\t\\t\\t\\t\\t\\t\\t\",\"controller\":\"*\",\"endpoint\":\"http\",\"instance\":\"10.244.1.4:19000\",\"job\":\"person-application-1-5\",\"namespace\":\"default\",\"pod\":\"person-application-1.5-5dcc65c754-8xh22\",\"service\":\"person-application-1-5\",\"url\":\"*\"},\"value\":[1536200364.286,\"0\"]},{\"metric\":{\"POD\":\"person-application-1.5-5dcc65c754-8xh22\",\"application\":\"person-1.5\\t\\t\\t\\t\\t\\t\\t\\t\",\"controller\":\"com.satish.monitoring.web.rest.PersonResource\",\"endpoint\":\"http\",\"instance\":\"10.244.1.4:19000\",\"job\":\"person-application-1-5\",\"namespace\":\"default\",\"pod\":\"person-application-1.5-5dcc65c754-8xh22\",\"service\":\"person-application-1-5\",\"url\":\"[GET]/person\"},\"value\":[1536200364.286,\"0\"]}]}}";
public void testParser() {
DefaultQueryResult<VectorData> result = ConvertUtil.convertQueryResultString(testVectorData);
System.out.println("-----" +result.getResult().size());
for(Data data : result.getResult()) {
System.out.println("=======>" + data);
}
}
}

View File

@ -0,0 +1,5 @@
Manifest-Version: 1.0
Built-By: mckang
Build-Jdk: 1.8.0_144
Created-By: Maven Integration for Eclipse

View File

@ -0,0 +1,7 @@
#Generated by Maven Integration for Eclipse
#Fri Sep 07 12:58:14 KST 2018
version=0.1-SNAPSHOT
groupId=com.bdwise.prometheus.client
m2e.projectName=promql_client
m2e.projectLocation=/Users/mckang/playground/prometheus_dev/promql_client
artifactId=promql_client

View File

@ -0,0 +1,30 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bdwise.prometheus.client</groupId>
<artifactId>promql_client</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>promql_client</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.1</version>
</dependency>
</dependencies>
</project>