Skip to content

Commit 6c44c37

Browse files
Merge pull request #126 from StefanScherer/add-prometheus
Add prometheus
2 parents 53af14a + 9f45e57 commit 6c44c37

4 files changed

Lines changed: 46 additions & 0 deletions

File tree

prometheus/Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# escape=`
2+
FROM microsoft/windowsservercore AS tar
3+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
4+
RUN Invoke-WebRequest 'http://www.7-zip.org/a/7z1604-x64.msi' -OutFile '7z.msi' -UseBasicParsing
5+
RUN Start-Process msiexec.exe -ArgumentList '/i', '7z.msi', '/quiet', '/norestart' -NoNewWindow -Wait
6+
7+
ENV PROMETHEUS_VERSION 1.6.1
8+
9+
RUN Invoke-WebRequest $('https://github.com/prometheus/prometheus/releases/download/v{0}/prometheus-{0}.windows-amd64.tar.gz' -f $env:PROMETHEUS_VERSION) -OutFile 'prometheus.tar.gz' -UseBasicParsing
10+
RUN & 'C:\Program Files\7-Zip\7z.exe' x prometheus.tar.gz
11+
RUN & 'C:\Program Files\7-Zip\7z.exe' x prometheus.tar
12+
RUN Rename-Item -Path $('C:\prometheus-{0}.windows-amd64' -f $env:PROMETHEUS_VERSION) -NewName 'C:\download'
13+
14+
FROM microsoft/nanoserver
15+
16+
COPY --from=tar /download/prometheus.exe /bin/prometheus.exe
17+
COPY --from=tar /download/promtool.exe /bin/promtool.exe
18+
COPY --from=tar /download/prometheus.yml /etc/prometheus/prometheus.yml
19+
COPY --from=tar /download/console_libraries/ /etc/prometheus/
20+
COPY --from=tar /download/consoles/ /etc/prometheus/
21+
22+
EXPOSE 9090
23+
VOLUME C:\prometheus
24+
WORKDIR C:\prometheus
25+
ENTRYPOINT [ "C:\\bin\\prometheus.exe" ]
26+
CMD [ "-config.file=/etc/prometheus/prometheus.yml", `
27+
"-storage.local.path=/prometheus", `
28+
"-web.console.libraries=/etc/prometheus/console_libraries", `
29+
"-web.console.templates=/etc/prometheus/consoles" ]

prometheus/build.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
. $PSScriptRoot\..\update-docker-rc.ps1
2+
3+
docker build -t prometheus .

prometheus/push.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$version=$(select-string -Path Dockerfile -Pattern "ENV PROMETHEUS_VERSION").ToString().split()[-1]
2+
docker tag prometheus stefanscherer/prometheus-windows:$version
3+
docker tag prometheus stefanscherer/prometheus-windows:latest
4+
docker push stefanscherer/prometheus-windows:$version
5+
docker push stefanscherer/prometheus-windows:latest

prometheus/test.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
docker run --name prometheus -d -p 9090:9090 prometheus
2+
Start-Sleep -Seconds 20
3+
4+
$req = Invoke-WebRequest http://$(docker inspect -f '{{ .NetworkSettings.Networks.nat.IPAddress }}' prometheus):9090/graph -UseBasicParsing
5+
$code = $req.statuscode
6+
$content = $req.content
7+
if($code -ne 200 -or !($content.Contains('prometheus.io'))){
8+
throw "Prometheus test failed!"
9+
}

0 commit comments

Comments
 (0)