diff --git a/.github/workflows/maven-publish-central.yml.old b/.github/workflows/maven-publish-central.yml.old
deleted file mode 100644
index 3432fd4..0000000
--- a/.github/workflows/maven-publish-central.yml.old
+++ /dev/null
@@ -1,24 +0,0 @@
-# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
-# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path
-
-name: Publish package to the Maven Central Repository
-on:
- release:
- types: [created]
-jobs:
- publish:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: Set up Maven Central Repository
- uses: actions/setup-java@v1
- with:
- java-version: 11
- server-id: ossrh
- server-username: MAVEN_USERNAME
- server-password: MAVEN_PASSWORD
- - name: Publish package
- run: mvn -B deploy
- env:
- MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
- MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
\ No newline at end of file
diff --git a/.github/workflows/maven-publish-package.yml b/.github/workflows/maven-publish-package.yml
index 6a146cb..0255a47 100644
--- a/.github/workflows/maven-publish-package.yml
+++ b/.github/workflows/maven-publish-package.yml
@@ -21,6 +21,10 @@ jobs:
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
+ - if: github.event.release
+ name: Update version in pom.xml (Release only)
+ run: mvn -B versions:set -DnewVersion=${{ github.event.release.tag_name }} -DgenerateBackupPoms=false
+
- name: Build with Maven
run: mvn -B package --file pom.xml
diff --git a/README.md b/README.md
index 7a0b32f..a43f11d 100644
--- a/README.md
+++ b/README.md
@@ -13,13 +13,20 @@ It can be importer in your Maven project with
```
- ch.postfinance.prometheus
- apache-exporter
- v1.0.0
+ com.github.postfinance.prometheus
+ apache-exporter
+ 0.0.0-SNAPSHOT
```
+The Apache ModStatus URL where the metrics are read, can be configured with
+
+* A System Property: httpdModStatusUrl
+* An Environment Property: HTTPD_MOD_STATUS_URL
+
+The default value is http://localhost/server-status?auto
+
To obtain the metrics, use the method:
diff --git a/pom.xml b/pom.xml
index e4aa6b8..2b6f874 100644
--- a/pom.xml
+++ b/pom.xml
@@ -66,40 +66,9 @@
-
-
-
github
diff --git a/src/main/java/ch/postfinance/prometheus/ApacheExporter.java b/src/main/java/ch/postfinance/prometheus/ApacheExporter.java
index f431567..7fded1c 100644
--- a/src/main/java/ch/postfinance/prometheus/ApacheExporter.java
+++ b/src/main/java/ch/postfinance/prometheus/ApacheExporter.java
@@ -136,7 +136,7 @@ private void mapStatusToMetrics(String statusData) {
String readApacheStatus() throws IOException, InterruptedException {
HttpRequest request = HttpRequest.newBuilder()
- .uri(URI.create("http://localhost/server-status?auto"))
+ .uri(URI.create(getStatusUrl()))
.timeout(Duration.ofSeconds(5))
.GET()
.build();
@@ -204,4 +204,18 @@ static String mapToState(int scoreValue) {
return "unknown";
}
+ static String getStatusUrl(){
+
+ String statusUrl = System.getProperty("httpdModStatusUrl");
+
+ if(statusUrl == null || statusUrl.trim().isEmpty()) {
+ statusUrl = System.getenv("HTTPD_MOD_STATUS_URL");
+
+ if(statusUrl == null || statusUrl.trim().isEmpty())
+ statusUrl = "http://localhost/server-status?auto";
+ }
+
+ return statusUrl;
+ }
+
}
diff --git a/src/test/java/ch/postfinance/prometheus/ApacheExporterTest.java b/src/test/java/ch/postfinance/prometheus/ApacheExporterTest.java
index a2c1159..b8ced69 100644
--- a/src/test/java/ch/postfinance/prometheus/ApacheExporterTest.java
+++ b/src/test/java/ch/postfinance/prometheus/ApacheExporterTest.java
@@ -12,7 +12,7 @@ public class ApacheExporterTest {
public void export() {
ApacheExporter exporter = new ApacheExporter();
try {
- for (int i = 0; i < 2; i++) {
+ for (int i = 0; i < 5; i++) {
System.out.println(exporter.export());
Thread.sleep(1000);
}
@@ -20,4 +20,16 @@ public void export() {
fail(e.getMessage());
}
}
+
+ @Test
+ public void testProperty(){
+
+ assertEquals(ApacheExporter.getStatusUrl(), "http://localhost/server-status?auto");
+
+ System.setProperty("httpdModStatusUrl", "http://e1-xxx-alsu001/server-status?auto");
+
+ assertEquals(ApacheExporter.getStatusUrl(), "http://e1-xxx-alsu001/server-status?auto");
+
+
+ }
}
\ No newline at end of file