Skip to content

Commit

Permalink
1.6.3
Browse files Browse the repository at this point in the history
* Fix docs
* Update jars
  • Loading branch information
pambrose authored Dec 22, 2019
1 parent 6f72a28 commit 69fb4e5
Show file tree
Hide file tree
Showing 27 changed files with 430 additions and 574 deletions.
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
language: java

jdk:
#- openjdk8
#- oraclejdk11
- openjdk11
#- openjdk8

before_script:
- chmod +x gradlew

script:
- ./gradlew check jacocoTestReport

after_success:
- bash <(curl -s https://codecov.io/bash)
- ./gradlew jacocoTestReport coveralls
# - ./mvnw jacoco:report coveralls:report

notifications:
email:
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=1.6.2
VERSION=1.6.3

default: compile

Expand All @@ -14,7 +14,7 @@ jars:
./gradlew agentJar proxyJar

tests:
./gradlew check
./gradlew check jacocoTestReport

config:
java -jar ./etc/jars/tscfg-0.9.95.jar --spec etc/config/config.conf --pn io.prometheus.common --cn ConfigVals --dd src/main/java/io/prometheus/common
Expand Down Expand Up @@ -49,3 +49,5 @@ tree:
versioncheck:
./gradlew dependencyUpdates

depends:
./gradlew dependencies
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

[![JitPack](https://jitpack.io/v/pambrose/prometheus-proxy.svg)](https://jitpack.io/#pambrose/prometheus-proxy)
[![Build Status](https://travis-ci.org/pambrose/prometheus-proxy.svg?branch=master)](https://travis-ci.org/pambrose/prometheus-proxy)
[![Coverage Status](https://coveralls.io/repos/github/pambrose/prometheus-proxy/badge.svg?branch=master)](https://coveralls.io/github/pambrose/prometheus-proxy?branch=master)
[![codebeat badge](https://codebeat.co/badges/8dbe1dc6-628e-44a4-99f9-d468831ff0cc)](https://codebeat.co/projects/github-com-pambrose-prometheus-proxy-master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/422df508473443df9fbd8ea00fdee973)](https://www.codacy.com/app/pambrose/prometheus-proxy?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=pambrose/prometheus-proxy&amp;utm_campaign=Badge_Grade)
[![codecov](https://codecov.io/gh/pambrose/prometheus-proxy/branch/master/graph/badge.svg)](https://codecov.io/gh/pambrose/prometheus-proxy)
[![Coverage Status](https://coveralls.io/repos/github/pambrose/prometheus-proxy/badge.svg?branch=master)](https://coveralls.io/github/pambrose/prometheus-proxy?branch=master)
[![Kotlin](https://img.shields.io/badge/%20language-Kotlin-red.svg)](https://kotlinlang.org/)

[Prometheus](https://prometheus.io) is an excellent systems monitoring and alerting toolkit, which uses a pull model for
Expand Down Expand Up @@ -96,8 +97,8 @@ scrape_configs:
The docker images are available via:
```bash
docker pull pambrose/prometheus-proxy:1.6.2
docker pull pambrose/prometheus-agent:1.6.2
docker pull pambrose/prometheus-proxy:1.6.3
docker pull pambrose/prometheus-agent:1.6.3
```

Start a proxy container with:
Expand All @@ -106,15 +107,15 @@ Start a proxy container with:
docker run --rm -p 8082:8082 -p 8092:8092 -p 50051:50051 -p 8080:8080 \
--env ADMIN_ENABLED=true \
--env METRICS_ENABLED=true \
pambrose/prometheus-proxy:1.6.2
pambrose/prometheus-proxy:1.6.3
```

Start an agent container with:

```bash
docker run --rm -p 8083:8083 -p 8093:8093 \
--env AGENT_CONFIG='https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf' \
pambrose/prometheus-agent:1.6.2
pambrose/prometheus-agent:1.6.3
```

Using the config file [simple.conf](https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf),
Expand All @@ -130,7 +131,7 @@ is in your current directory, run an agent container with:
docker run --rm -p 8083:8083 -p 8093:8093 \
--mount type=bind,source="$(pwd)"/prom-agent.conf,target=/app/prom-agent.conf \
--env AGENT_CONFIG=prom-agent.conf \
pambrose/prometheus-agent:1.6.2
pambrose/prometheus-agent:1.6.3
```

**Note:** The `WORKDIR` of the proxy and agent images is `/app`, so make sure
Expand All @@ -157,9 +158,9 @@ The only required argument is an agent config value, which should have an `agent
| --agent_port, -a | AGENT_PORT <br> proxy.agent.port | 50051 | gRPC listen port for agents |
| --admin, -r | ADMIN_ENABLED <br> proxy.admin.enabled | false | Enable admin servlets |
| --admin_port, -i | ADMIN_PORT <br> proxy.admin.port | 8092 | Admin servlets port |
| --debug, -b | DEBUG_ENABLED <br> proxy.admin.debugEnabled | false | Enable proxy debug servlet<br>on admin port|
| --metrics, -e | METRICS_ENABLED <br> proxy.metrics.enabled | false | Enable proxy metrics |
| --metrics_port, -m | METRICS_PORT <br> proxy.metrics.port | 8082 | Proxy metrics listen port |
| --debug, -b | DEBUG_ENABLED <br> proxy.metrics.debugEnabled | false | Enable proxy debug servlet<br>on admin port|
| --cert, -t | CERT_CHAIN_FILE_PATH <br> proxy.tls.certChainFilePath | | Certificate chain file path |
| --key, -k | PRIVATE_KEY_FILE_PATH <br> proxy.tls.privateKeyFilePath | | Private key file path |
| --trust, -s | TRUST_CERT_COLLECTION_FILE_PATH <br> proxy.tls.trustCertCollectionFilePath | | Trust certificate collection file path |
Expand All @@ -177,9 +178,9 @@ The only required argument is an agent config value, which should have an `agent
| --name, -n | AGENT_NAME <br> agent.name | | Agent name |
| --admin, -r | ADMIN_ENABLED <br> agent.admin.enabled | false | Enable admin servlets |
| --admin_port, -i | ADMIN_PORT <br> agent.admin.port | 8093 | Admin servlets port |
| --debug, -b | DEBUG_ENABLED <br> agent.admin.debugEnabled | false | Enable agent debug servlet<br>on admin port|
| --metrics, -e | METRICS_ENABLED <br> agent.metrics.enabled | false | Enable agent metrics |
| --metrics_port, -m | METRICS_PORT <br> agent.metrics.port | 8083 | Agent metrics listen port |
| --debug, -b | DEBUG_ENABLED <br> agent.metrics.debugEnabled | false | Enable agent debug servlet<br>on admin port|
| --chunk | CHUNK_CONTENT_SIZE_KBS <br> agent.chunkContentSizeKbs | 32 | Threshold for chunking data to Proxy and buffer size (KBs) |
| --gzip | MIN_GZIP_SIZE_BYTES <br> agent.minGzipSizeBytes | 1024 | Minimum size for content to be gzipped (Bytes) |
| --cert, -t | CERT_CHAIN_FILE_PATH <br> agent.tls.certChainFilePath | | Certificate chain file path |
Expand Down Expand Up @@ -249,15 +250,15 @@ docker run --rm -p 8082:8082 -p 8092:8092 -p 50440:50440 -p 8080:8080 \
--env PROXY_CONFIG=tls-no-mutual-auth.conf \
--env ADMIN_ENABLED=true \
--env METRICS_ENABLED=true \
pambrose/prometheus-proxy:1.6.2
pambrose/prometheus-proxy:1.6.3

docker run --rm -p 8083:8083 -p 8093:8093 \
--mount type=bind,source="$(pwd)"/testing/certs,target=/app/testing/certs \
--mount type=bind,source="$(pwd)"/examples/tls-no-mutual-auth.conf,target=/app/tls-no-mutual-auth.conf \
--env AGENT_CONFIG=tls-no-mutual-auth.conf \
--env PROXY_HOSTNAME=mymachine.lan:50440 \
--name docker-agent \
pambrose/prometheus-agent:1.6.2
pambrose/prometheus-agent:1.6.3
```

**Note:** The `WORKDIR` of the proxy and agent images is `/app`, so make sure
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 \
--env AGENT_CONFIG='https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf' \
--env PROXY_HOSTNAME=mymachine.lan \
pambrose/prometheus-agent:1.6.2
pambrose/prometheus-agent:1.6.3
2 changes: 1 addition & 1 deletion bin/docker-proxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

docker run --rm -p 8082:8082 -p 8092:8092 -p 50051:50051 -p 8080:8080 \
--env PROXY_CONFIG='https://raw.githubusercontent.com/pambrose/prometheus-proxy/master/examples/simple.conf' \
pambrose/prometheus-proxy:1.6.2
pambrose/prometheus-proxy:1.6.3
36 changes: 24 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,33 @@ plugins {
id 'com.google.protobuf' version '0.8.10'
id "com.github.ben-manes.versions" version '0.27.0'
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'jacoco'
id 'com.github.kt3k.coveralls' version '2.8.4'
}

group = 'io.prometheus'
version = '1.6.2'
version = '1.6.3'

sourceCompatibility = 1.8
targetCompatibility = 1.8

def annotationVersion = '1.3.2'
def coroutinesVersion = '1.3.3'
def dropwizardVersion = '4.1.2'
def grpcVersion = '1.25.0'
def prometheusVersion = '0.8.0'
def grpcVersion = '1.26.0'
def jcommanderVersion = '1.78'
def jettyVersion = '9.4.22.v20191022'
def junitVersion = '5.5.2'
def kluentVersion = '1.58'
def ktorVersion = '1.2.6'
def logbackVersion = '1.2.3'
def loggingVersion = '1.7.8'
def protocVersion = '3.10.0'
def prometheusVersion = '0.8.0'
def protocVersion = '3.11.2'
def serializationVersion = '0.13.0'
def slf4jVersion = '1.7.28'
def typesafeVersion = '1.3.4'
def utilsVersion = '1.1.13'
def typesafeVersion = '1.4.0'
def utilsVersion = '1.1.14'
def zipkinVersion = '5.9.1'

repositories {
Expand Down Expand Up @@ -125,14 +127,24 @@ artifacts {
//archives javadocJar
}

/*
jacocoTestReport {
reports {
xml.enabled = true // coveralls plugin depends on xml format report
html.enabled = true
}
reports {
xml.enabled true
html.enabled true
}

afterEvaluate {
getClassDirectories().setFrom(files(classDirectories.files.collect {
fileTree(dir: it,
excludes: [
'**/ConfigVals*',
'io/prometheus/grpc/**'
])
}))
}
}
*/

check.dependsOn jacocoTestReport

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
Expand Down
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.6.2'
image: 'pambrose/prometheus-proxy:1.6.3'
ports:
- '8080:8080'
- '8082:8082'
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/prometheus/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

@VersionAnnotation(version = "1.6.2", date = "12/18/19")
@VersionAnnotation(version = "1.6.3", date = "12/21/19")
package io.prometheus;

import io.prometheus.common.VersionAnnotation;
114 changes: 55 additions & 59 deletions src/main/kotlin/io/prometheus/Agent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,28 @@ class Agent(val options: AgentOptions,
val pathManager = AgentPathManager(this)
val grpcService = AgentGrpcService(this, options, inProcessServerName)
var agentId: String by nonNullableReference("")

lateinit var metrics: AgentMetrics
val metrics by lazy { AgentMetrics(this) }

init {
fun toPlainText() = """
Prometheus Agent Info [${getVersionDesc(false)}]
Uptime: ${upTime.format(true)}
AgentId: $agentId
AgentName: $agentName
ProxyHost: $proxyHost
Admin Service:
${if (isAdminEnabled) adminService.toString() else "Disabled"}
Metrics Service:
${if (isMetricsEnabled) metricsService.toString() else "Disabled"}
""".trimIndent()

logger.info { "Assigning agent name: $agentName" }
logger.info { "Assigning proxy reconnect pause time: ${agentConfigVals.reconnectPauseSecs.seconds}" }

if (isMetricsEnabled)
metrics = AgentMetrics(this)

initService {
if (options.debugEnabled)
addServlet(DEBUG,
Expand All @@ -108,6 +120,43 @@ class Agent(val options: AgentOptions,
}

override fun run() {

fun connectToProxy() {
// Reset gRPC stubs if previous iteration had a successful connection, i.e., the agentId != ""
if (agentId.isNotEmpty()) {
grpcService.resetGrpcStubs()
logger.info { "Resetting agentId" }
agentId = ""
}

// Reset values for each connection attempt
pathManager.clear()
scrapeRequestBacklogSize.set(0)
lastMsgSentMark = clock.markNow()

if (grpcService.connectAgent()) {
grpcService.registerAgent(initialConnectionLatch)
pathManager.registerPaths()

val connectionContext = AgentConnectionContext()
grpcService.readRequestsFromProxy(agentHttpService, connectionContext)

runBlocking {
launch(Dispatchers.Default) { startHeartBeat(connectionContext) }

launch(Dispatchers.Default) { grpcService.writeResponsesToProxyUntilDisconnected(connectionContext) }

for (scrapeRequestAction in connectionContext.scrapeRequestsChannel) {
launch(Dispatchers.Default) {
// The fetch occurs during the invoke()
val scrapeResponse = scrapeRequestAction.invoke()
connectionContext.scrapeResultsChannel.send(scrapeResponse)
}
}
}
}
}

while (isRunning) {
try {
connectToProxy()
Expand All @@ -117,7 +166,7 @@ class Agent(val options: AgentOptions,
logger.info { "Disconnected from proxy at $proxyHost" }
} catch (e: Throwable) {
// Catch anything else to avoid exiting retry loop
logger.warn(e) { "Throwable caught" }
logger.warn { "Throwable caught ${e.simpleClassName} ${e.message}" }
} finally {
logger.info { "Waited ${reconnectLimiter.acquire().roundToInt().seconds} to reconnect" }
}
Expand All @@ -137,42 +186,6 @@ class Agent(val options: AgentOptions,
agentConfigVals.scrapeRequestBacklogUnhealthySize))
}

private fun connectToProxy() {
// Reset gRPC stubs if previous iteration had a successful connection, i.e., the agentId != ""
if (agentId.isNotEmpty()) {
grpcService.resetGrpcStubs()
logger.info { "Resetting agentId" }
agentId = ""
}

// Reset values for each connection attempt
pathManager.clear()
scrapeRequestBacklogSize.set(0)
lastMsgSentMark = clock.markNow()

if (grpcService.connectAgent()) {
grpcService.registerAgent(initialConnectionLatch)
pathManager.registerPaths()

val connectionContext = AgentConnectionContext()
grpcService.readRequestsFromProxy(agentHttpService, connectionContext)

runBlocking {
launch(Dispatchers.Default) { startHeartBeat(connectionContext) }

launch(Dispatchers.Default) { grpcService.writeResponsesToProxyUntilDisconnected(connectionContext) }

for (scrapeRequestAction in connectionContext.scrapeRequestsChannel) {
launch(Dispatchers.Default) {
// The fetch occurs during the invoke()
val scrapeResponse = scrapeRequestAction.invoke()
connectionContext.scrapeResultsChannel.send(scrapeResponse)
}
}
}
}
}

private suspend fun startHeartBeat(connectionContext: AgentConnectionContext) =
if (agentConfigVals.heartbeatEnabled) {
val heartbeatPauseTime = agentConfigVals.heartbeatCheckPauseMillis.milliseconds
Expand Down Expand Up @@ -213,23 +226,6 @@ class Agent(val options: AgentOptions,
super.shutDown()
}

private fun toPlainText() =
"""
Prometheus Agent Info [${getVersionDesc(false)}]
Uptime: ${upTime.format(true)}
AgentId: $agentId
AgentName: $agentName
ProxyHost: $proxyHost
Admin Service:
${if (isAdminEnabled) adminService.toString() else "Disabled"}
Metrics Service:
${if (isMetricsEnabled) metricsService.toString() else "Disabled"}
""".trimIndent()

override fun toString() =
toStringElements {
add("agentId", agentId)
Expand Down
Loading

0 comments on commit 69fb4e5

Please sign in to comment.