Skip to content

Commit

Permalink
Update to 1.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
pambrose committed Nov 7, 2017
1 parent e6c97b6 commit 418e5bc
Show file tree
Hide file tree
Showing 59 changed files with 933 additions and 86 deletions.
15 changes: 15 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
#
# Copyright 2017, Paul Ambrose All rights reserved.
#
# 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.
#
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
VERSION=1.2.3
VERSION=1.2.4

default: build

build:
./mvnw -DskipTests=true clean package

config:
java -jar ./etc/jars/tscfg-0.8.0.jar --spec etc/config/config.conf --pn io.prometheus.common --cn ConfigVals --dd src/main/java/io/prometheus/common
java -jar ./etc/jars/tscfg-0.8.3.jar --spec etc/config/config.conf --pn io.prometheus.common --cn ConfigVals --dd src/main/java/io/prometheus/common

tests:
./mvnw test

clean:
./mvnw -DskipTests=true clean
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ scrape_configs:
The docker images are available via:
```bash
$ docker pull pambrose/prometheus-proxy:1.2.3
$ docker pull pambrose/prometheus-agent:1.2.3
$ docker pull pambrose/prometheus-proxy:1.2.4
$ docker pull pambrose/prometheus-agent:1.2.4
```

Start the proxy and an agent in separate shells on your local machine:
Expand All @@ -94,14 +94,14 @@ Start the proxy and an agent in separate shells on your local machine:
$ docker run --rm -p 8082:8082 -p 8092:8092 -p 50051:50051 -p 8080:8080 \
-e HOSTNAME=${HOSTNAME} \
-e METRICS_ENABLED=true \
pambrose/prometheus-proxy:1.2.3
pambrose/prometheus-proxy:1.2.4
```

```bash
$ docker run --rm -p 8083:8083 -p 8093:8093 \
-e HOSTNAME=${HOSTNAME} \
-e AGENT_CONFIG='https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf' \
pambrose/prometheus-agent:1.2.3
pambrose/prometheus-agent:1.2.4
```

Using the config file [simple.conf](https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf),
Expand Down
2 changes: 1 addition & 1 deletion bin/docker-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
docker run --rm -p 8083:8083 -p 8093:8093 \
-e HOSTNAME=${HOSTNAME} \
-e AGENT_CONFIG='https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf' \
pambrose/prometheus-agent:1.2.3
pambrose/prometheus-agent:1.2.4
2 changes: 1 addition & 1 deletion bin/docker-proxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
docker run --rm -p 8082:8082 -p 8092:8092 -p 50051:50051 -p 8080:8080 \
-e HOSTNAME=${HOSTNAME} \
-e PROXY_CONFIG='https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf' \
pambrose/prometheus-proxy:1.2.3
pambrose/prometheus-proxy:1.2.4
2 changes: 1 addition & 1 deletion etc/compose/proxy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
prometheus-proxy:
autoredeploy: true
image: 'pambrose/prometheus-proxy:1.2.3'
image: 'pambrose/prometheus-proxy:1.2.4'
ports:
- '8080:8080'
- '8082:8082'
Expand Down
Binary file not shown.
16 changes: 16 additions & 0 deletions logback/docker-logback.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<!--
~ Copyright 2017, Paul Ambrose All rights reserved.
~
~ 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.
-->

<configuration scan="true" scanPeriod="30 seconds">

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
Expand Down
58 changes: 44 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2017, Paul Ambrose All rights reserved.
~
~ 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.
-->

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>io.prometheus</groupId>
<artifactId>prometheus-proxy</artifactId>
<version>1.2.3-SNAPSHOT</version>
<version>1.2.4-SNAPSHOT</version>

<properties>
<config.version>1.3.1</config.version>
<grpc.version>1.3.0</grpc.version>
<grpc.plugin.version>1.3.0</grpc.plugin.version>
<protobuf.version>3.2.0</protobuf.version>
<prometheus.version>0.1.0</prometheus.version>
<jcommander.version>1.72</jcommander.version>
<config.version>1.3.2</config.version>
<grpc.version>1.7.0</grpc.version>
<grpc.plugin.version>1.7.0</grpc.plugin.version>
<protobuf.version>3.4.0</protobuf.version>
<protobuf.plugin.version>0.5.0</protobuf.plugin.version>
<guava.version>19.0</guava.version>
<prometheus.version>0.0.22</prometheus.version>
<jcommander.version>1.69</jcommander.version>
<spark.version>2.6.0</spark.version>
<jetty.version>9.4.4.v20170414</jetty.version>
<okhttp.version>3.8.0</okhttp.version>
<auto.version>1.4.1</auto.version>
<spark.version>2.7.0</spark.version>
<jetty.version>9.4.6.v20170531</jetty.version>
<okhttp.version>3.9.0</okhttp.version>
<auto.version>1.5.2</auto.version>
<grpc-prom.version>0.3.0</grpc-prom.version>
<metrics.version>3.2.2</metrics.version>
<brave.version>4.3.3</brave.version>
<zipkin-reporter.version>0.10.0</zipkin-reporter.version>
<metrics.version>4.0.0-alpha3</metrics.version>
<brave.version>4.9.1</brave.version>
<zipkin-reporter.version>1.1.2</zipkin-reporter.version>

<logback.version>1.2.3</logback.version>
<slf4j.version>1.7.25</slf4j.version>
Expand Down Expand Up @@ -155,6 +171,12 @@
<version>${metrics.version}</version>
</dependency>

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jmx</artifactId>
<version>${metrics.version}</version>
</dependency>

<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
Expand Down Expand Up @@ -203,6 +225,14 @@
<version>${brave.version}</version>
</dependency>

<!--
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-instrumentation-sparkjava</artifactId>
<version>${brave.version}</version>
</dependency>
-->

<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-okhttp</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion release.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Release Notes
# Release Creation Notes

1) Create branch

Expand Down
47 changes: 31 additions & 16 deletions src/main/java/io/prometheus/Agent.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2017, Paul Ambrose All rights reserved.
*
* 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.
*/

package io.prometheus;

import com.google.common.base.MoreObjects;
Expand Down Expand Up @@ -133,9 +149,9 @@ public Agent(final AgentOptions options, final String inProcessServerName, final
this.pathConfigs = this.getConfigVals().pathConfigs.stream()
.map(v -> ImmutableMap.of("name", v.name,
"path", v.path,
"pingUrl", v.url))
"url", v.url))
.peek(v -> logger.info("Proxy path /{} will be assigned to {}",
v.get("path"), v.get("pingUrl")))
v.get("path"), v.get("url")))
.collect(Collectors.toList());


Expand All @@ -150,12 +166,10 @@ public Agent(final AgentOptions options, final String inProcessServerName, final
}

this.resetGrpcStubs();

this.init();
}

public static void main(final String[] argv)
throws IOException, InterruptedException {
public static void main(final String[] argv) {
final AgentOptions options = new AgentOptions(argv, true);

logger.info(Utils.getBanner("banners/agent.txt"));
Expand Down Expand Up @@ -200,8 +214,8 @@ protected void run() {
}

@Override
protected void registerHealtChecks() {
super.registerHealtChecks();
protected void registerHealthChecks() {
super.registerHealthChecks();
this.getHealthCheckRegistry()
.register("scrape_response_queue_check",
queueHealthCheck(scrapeResponseQueue,
Expand Down Expand Up @@ -278,6 +292,7 @@ private void resetGrpcStubs() {
if (this.zipkinReporter != null && this.getConfigVals().grpc.zipkinReportingEnabled)
interceptors.add(BraveGrpcClientInterceptor.create(this.zipkinReporter.getBrave()));
*/

this.blockingStubRef.set(newBlockingStub(intercept(this.getChannel(), interceptors)));
this.asyncStubRef.set(newStub(intercept(this.getChannel(), interceptors)));
}
Expand Down Expand Up @@ -349,7 +364,7 @@ private ScrapeResponse fetchUrl(final ScrapeRequest scrapeRequest) {
}

// If successful, this will create an agentContxt on the Proxy and an interceptor will
// add an agent_id to the headers
// add an agent_id to the headers`
private boolean connectAgent() {
try {
logger.info("Connecting to proxy at {}...", this.getProxyHost());
Expand Down Expand Up @@ -386,7 +401,7 @@ private void registerPaths()
throws RequestFailureException {
for (final Map<String, String> agentConfig : this.pathConfigs) {
final String path = agentConfig.get("path");
final String url = agentConfig.get("pingUrl");
final String url = agentConfig.get("url");
this.registerPath(path, url);
}
}
Expand Down Expand Up @@ -458,7 +473,7 @@ private Runnable readRequestAction(final ScrapeRequest request) {
}

private void readRequestsFromProxy(final AtomicBoolean disconnected) {
final StreamObserver<ScrapeRequest> streamObserver =
final StreamObserver<ScrapeRequest> observer =
new StreamObserver<ScrapeRequest>() {
@Override
public void onNext(final ScrapeRequest request) {
Expand All @@ -477,11 +492,13 @@ public void onCompleted() {
disconnected.set(true);
}
};
this.getAsyncStub().readRequestsFromProxy(AgentInfo.newBuilder().setAgentId(this.getAgentId()).build(), streamObserver);
final AgentInfo agentInfo = AgentInfo.newBuilder().setAgentId(this.getAgentId()).build();
this.getAsyncStub().readRequestsFromProxy(agentInfo, observer);
}

private void writeResponsesToProxyUntilDisconnected(final AtomicBoolean disconnected) {
final StreamObserver<ScrapeResponse> responseObserver = this.getAsyncStub().writeResponsesToProxy(
final long checkMillis = this.getConfigVals().internal.scrapeResponseQueueCheckMillis;
final StreamObserver<ScrapeResponse> observer = this.getAsyncStub().writeResponsesToProxy(
new StreamObserver<Empty>() {
@Override
public void onNext(Empty empty) {
Expand All @@ -501,13 +518,12 @@ public void onCompleted() {
}
});

final long checkMillis = this.getConfigVals().internal.scrapeResponseQueueCheckMillis;
while (!disconnected.get()) {
try {
// Set a short timeout to check if client has disconnected
final ScrapeResponse response = this.scrapeResponseQueue.poll(checkMillis, TimeUnit.MILLISECONDS);
if (response != null) {
responseObserver.onNext(response);
observer.onNext(response);
this.markMsgSent();
}
}
Expand All @@ -517,8 +533,7 @@ public void onCompleted() {
}

logger.info("Disconnected from proxy at {}", this.getProxyHost());

responseObserver.onCompleted();
observer.onCompleted();
}

private void markMsgSent() {
Expand Down
28 changes: 20 additions & 8 deletions src/main/java/io/prometheus/Proxy.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2017, Paul Ambrose All rights reserved.
*
* 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.
*/

package io.prometheus;

import com.codahale.metrics.health.HealthCheck;
Expand All @@ -22,7 +38,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -51,8 +66,7 @@ public class Proxy
public Proxy(final ProxyOptions options,
final int proxyPort,
final String inProcessServerName,
final boolean testMode)
throws IOException {
final boolean testMode) {
super(options.getConfigVals(),
AdminConfig.create(options.isAdminEnabled(),
options.getAdminPort(),
Expand All @@ -71,12 +85,10 @@ public Proxy(final ProxyOptions options,
? new AgentContextCleanupService(this) : null;

this.addServices(this.grpcService, this.httpService, this.agentCleanupService);

this.init();
}

public static void main(final String[] argv)
throws IOException, InterruptedException {
public static void main(final String[] argv) {
final ProxyOptions options = new ProxyOptions(argv);

logger.info(Utils.getBanner("banners/proxy.txt"));
Expand Down Expand Up @@ -117,8 +129,8 @@ protected void run() {
}

@Override
protected void registerHealtChecks() {
super.registerHealtChecks();
protected void registerHealthChecks() {
super.registerHealthChecks();
this.getHealthCheckRegistry().register("grpc_service", this.grpcService.getHealthCheck());
this.getHealthCheckRegistry()
.register("scrape_response_map_check",
Expand Down
Loading

0 comments on commit 418e5bc

Please sign in to comment.