diff --git a/Makefile b/Makefile
index 1f81683c..08dd8d9c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION=1.0.0
+VERSION=1.1.0
default: build
@@ -27,8 +27,8 @@ report-coverage:
distro: build
mkdir target/distro
- mv target/proxy-1.0-jar-with-dependencies.jar target/distro/prometheus-proxy.jar
- mv target/agent-1.0-jar-with-dependencies.jar target/distro/prometheus-agent.jar
+ mv target/proxy-jar-with-dependencies.jar target/distro/prometheus-proxy.jar
+ mv target/agent-jar-with-dependencies.jar target/distro/prometheus-agent.jar
site:
./mvnw site
diff --git a/README.md b/README.md
index f0dc38a9..a0570bb9 100644
--- a/README.md
+++ b/README.md
@@ -84,8 +84,8 @@ scrape_configs:
The docker images are available via:
```bash
-$ docker pull pambrose/prometheus-proxy:1.0.0
-$ docker pull pambrose/prometheus-agent:1.0.0
+$ docker pull pambrose/prometheus-proxy:1.1.0
+$ docker pull pambrose/prometheus-agent:1.1.0
```
Start the proxy and an agent in separate shells on your local machine:
@@ -93,15 +93,15 @@ Start the proxy and an agent in separate shells on your local machine:
```bash
$ docker run --rm -p 8082:8082 -p 50051:50051 -p 8080:8080 \
-e HOSTNAME=${HOSTNAME} \
- -e ENABLE_METRICS=true \
- pambrose/prometheus-proxy:1.0.0
+ -e METRICS_ENABLED=true \
+ pambrose/prometheus-proxy:1.1.0
```
```bash
$ docker run --rm -p 8083:8083 \
-e HOSTNAME=${HOSTNAME} \
-e AGENT_CONFIG='https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf' \
- pambrose/prometheus-agent:1.0.0
+ pambrose/prometheus-agent:1.1.0
```
Using the config file [simple.conf](https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf),
@@ -129,7 +129,7 @@ The only required argument is an Agent config value, which should have an `agent
| -c --config | PROXY_CONFIG | | | Agent config file or url |
| -p --port | PROXY_PORT | proxy.http.port | 8080 | Proxy listen port |
| -a --agent_port | AGENT_PORT | proxy.agent.port | 50051 | Grpc listen port |
-| -e --metrics | ENABLE_METRICS | proxy.metrics.enabled | false | Enable proxy metrics |
+| -e --metrics | METRICS_ENABLED | proxy.metrics.enabled | false | Enable proxy metrics |
| -m --metrics_port | METRICS_PORT | proxy.metrics.port | 8082 | Proxy metrics listen port |
| -v --version | | | | Print version info and exit |
| -u --usage | | | | Print usage message and exit |
@@ -143,7 +143,7 @@ The only required argument is an Agent config value, which should have an `agent
| -c --config | AGENT_CONFIG | | | Agent config file or url (required) |
| -p --proxy | PROXY_HOSTNAME | agent.proxy.hostname | | Proxy hostname (can include :port) |
| -n --name | AGENT_NAME | agent.name | | Agent name |
-| -e --metrics | ENABLE_METRICS | agent.metrics.enabled | false | Enable agent metrics |
+| -e --metrics | METRICS_ENABLED | agent.metrics.enabled | false | Enable agent metrics |
| -m --metrics_port | METRICS_PORT | agent.metrics.port | 8083 | Agent metrics listen port |
| -v --version | | | | Print version info and exit |
| -u --usage | | | | Print usage message and exit |
diff --git a/bin/docker-agent.sh b/bin/docker-agent.sh
index 47333e6c..e285d17e 100755
--- a/bin/docker-agent.sh
+++ b/bin/docker-agent.sh
@@ -3,4 +3,4 @@
docker run --rm -p 8083:8083 \
-e HOSTNAME=${HOSTNAME} \
-e AGENT_CONFIG='https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf' \
- pambrose/prometheus-agent:1.0.0
\ No newline at end of file
+ pambrose/prometheus-agent:1.1.0
\ No newline at end of file
diff --git a/bin/docker-proxy.sh b/bin/docker-proxy.sh
index ebbaa764..ae18ac9e 100755
--- a/bin/docker-proxy.sh
+++ b/bin/docker-proxy.sh
@@ -3,4 +3,4 @@
docker run --rm -p 8082:8082 -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.0.0
\ No newline at end of file
+ pambrose/prometheus-proxy:1.1.0
\ No newline at end of file
diff --git a/etc/compose/proxy.yml b/etc/compose/proxy.yml
index b2483dc0..73164bfc 100644
--- a/etc/compose/proxy.yml
+++ b/etc/compose/proxy.yml
@@ -1,6 +1,6 @@
prometheus-proxy:
autoredeploy: true
- image: 'pambrose/prometheus-proxy:1.0.0'
+ image: 'pambrose/prometheus-proxy:1.1.0'
ports:
- '8080:8080'
- '8082:8082'
diff --git a/etc/config/config.conf b/etc/config/config.conf
index 96add341..6f73cc0d 100644
--- a/etc/config/config.conf
+++ b/etc/config/config.conf
@@ -1,6 +1,12 @@
proxy {
- http.port = 8080 // Listen port for proxied scrapes
+
+ http {
+ port = 8080 // Listen port for proxied scrapes
+ maxThreads = -1
+ minThreads = -1
+ idleTimeoutMillis = -1
+ }
agent.port = 50051 // Listen port for agent connections
diff --git a/pom.xml b/pom.xml
index a8d49677..f9fcd897 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,12 +6,12 @@
io.prometheus
prometheus-proxy
- 1.0-SNAPSHOT
+ 1.1.0-SNAPSHOT
1.3.1
- 1.2.0
- 1.2.0
+ 1.3.0
+ 1.3.0
3.2.0
0.5.0
19.0
@@ -19,6 +19,7 @@
1.69
2.6.0.RC0
3.7.0
+ 1.4.1
0.3.0
4.2.0
0.7.0
@@ -40,6 +41,9 @@
1.8
UTF-8
+
+ **/grpc/*.java, **/AutoValue_*
+ java
@@ -62,21 +66,10 @@
io.grpc
- grpc-protobuf
- ${grpc.version}
-
-
-
- io.grpc
- grpc-stub
+ grpc-all
${grpc.version}
-
- io.grpc
- grpc-netty
- ${grpc.version}
-
@@ -148,20 +141,16 @@
io.grpc
- grpc-protobuf
+ grpc-all
${grpc.version}
-
- io.grpc
- grpc-stub
- ${grpc.version}
-
- io.grpc
- grpc-netty
- ${grpc.version}
+ com.google.auto.value
+ auto-value
+ ${auto.version}
+ provided
@@ -354,7 +343,7 @@
package
- proxy-1.0
+ proxy
jar-with-dependencies
@@ -375,7 +364,7 @@
package
- agent-1.0
+ agent
jar-with-dependencies
@@ -534,6 +523,7 @@
**/grpc/*.class
**/ConfigVals*.class
**/ZipkinReporter*.class
+ **/AutoValue_*.class
diff --git a/src/main/java/io/prometheus/Agent.java b/src/main/java/io/prometheus/Agent.java
index fad22a07..2e2b58de 100644
--- a/src/main/java/io/prometheus/Agent.java
+++ b/src/main/java/io/prometheus/Agent.java
@@ -1,11 +1,12 @@
package io.prometheus;
-import com.beust.jcommander.JCommander;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.RateLimiter;
+import com.google.common.util.concurrent.ServiceManager;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.protobuf.Empty;
import io.grpc.ClientInterceptor;
@@ -22,16 +23,18 @@
import io.prometheus.agent.RequestFailureException;
import io.prometheus.client.Summary;
import io.prometheus.common.ConfigVals;
-import io.prometheus.common.MetricsServer;
-import io.prometheus.common.SystemMetrics;
+import io.prometheus.common.GenericService;
+import io.prometheus.common.GenericServiceListener;
+import io.prometheus.common.MetricsConfig;
import io.prometheus.common.Utils;
-import io.prometheus.common.ZipkinReporter;
+import io.prometheus.common.ZipkinConfig;
import io.prometheus.grpc.AgentInfo;
import io.prometheus.grpc.HeartBeatRequest;
import io.prometheus.grpc.HeartBeatResponse;
import io.prometheus.grpc.PathMapSizeRequest;
import io.prometheus.grpc.PathMapSizeResponse;
-import io.prometheus.grpc.ProxyServiceGrpc;
+import io.prometheus.grpc.ProxyServiceGrpc.ProxyServiceBlockingStub;
+import io.prometheus.grpc.ProxyServiceGrpc.ProxyServiceStub;
import io.prometheus.grpc.RegisterAgentRequest;
import io.prometheus.grpc.RegisterAgentResponse;
import io.prometheus.grpc.RegisterPathRequest;
@@ -45,7 +48,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.Closeable;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -73,186 +75,150 @@
import static java.util.concurrent.Executors.newCachedThreadPool;
public class Agent
- implements Closeable {
+ extends GenericService {
private static final Logger logger = LoggerFactory.getLogger(Agent.class);
- private final AtomicBoolean stopped = new AtomicBoolean(false);
- private final Map pathContextMap = Maps.newConcurrentMap(); // Map path to PathContext
- private final AtomicReference agentIdRef = new AtomicReference<>();
- private final AtomicLong lastMsgSent = new AtomicLong();
- private final ExecutorService heartbeatService = Executors.newFixedThreadPool(1);
- private final ExecutorService runService = Executors.newFixedThreadPool(1);
- private final CountDownLatch stoppedLatch = new CountDownLatch(1);
- private final CountDownLatch initialConnectionLatch = new CountDownLatch(1);
- private final OkHttpClient okHttpClient = new OkHttpClient();
-
- private final ConfigVals configVals;
+ private final Map pathContextMap = Maps.newConcurrentMap(); // Map path to PathContext
+ private final AtomicReference agentIdRef = new AtomicReference<>();
+ private final AtomicLong lastMsgSent = new AtomicLong();
+ private final ExecutorService heartbeatService = Executors.newFixedThreadPool(1);
+ private final CountDownLatch initialConnectionLatch = new CountDownLatch(1);
+ private final OkHttpClient okHttpClient = new OkHttpClient();
+ private final AtomicReference channelRef = new AtomicReference<>();
+ private final AtomicReference blockingStubRef = new AtomicReference<>();
+ private final AtomicReference asyncStubRef = new AtomicReference<>();
+
private final String inProcessServerName;
private final String agentName;
private final String hostname;
private final int port;
private final AgentMetrics metrics;
- private final ExecutorService executorService;
+ private final ExecutorService readRequestsExecutorService;
private final BlockingQueue scrapeResponseQueue;
private final RateLimiter reconnectLimiter;
- private final MetricsServer metricsServer;
private final List