Skip to content

Commit

Permalink
first working version
Browse files Browse the repository at this point in the history
  • Loading branch information
bcrickboom committed Apr 16, 2024
1 parent 597d8b2 commit 592039a
Show file tree
Hide file tree
Showing 16 changed files with 336 additions and 105 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: build-orthanc-prometheus

on:
push:
branches:
- '*'
tags:
- '*'

jobs:

build-orthanc-prometheus:
runs-on: ubuntu-latest
steps:

- name: checkout
uses: actions/checkout@v3

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker (orthanc-prometheus)
id: meta-orthanc-prometheus
uses: docker/metadata-action@v4
with:
images: orthancteam/orthanc-prometheus
labels: |
org.opencontainers.image.title=orthanc-prometheus
org.opencontainers.image.vendor=Orthanc Team SRL
- name: Build and push orthanc-prometheus Docker image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta-orthanc-prometheus.outputs.tags }}
labels: ${{ steps.meta-orthanc-prometheus.outputs.labels }}

- name: Docker Hub Description (orthanc-prometheus)
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: orthancteam/orthanc-prometheus
short-description: A Prometheus pushing Orthanc metrics to a remote write destination.
readme-filepath: README.md
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/orthanc-secrets
/.env
/.idea
/passwords
*/secrets/
*.env
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Orthanc-monitoring
# Orthanc-prometheus

## Summary
Here is only a basic Orthanc with a Postgres.
Based on the official `prom/prometheus` Docker image, here is an extra layer to allow the configuration of the scrap (Orthanc only) and remote write through environment variables.

But these 2 services, as well as the host system and the containers, are monitored thanks to Prometheus.
Grafana is also there to show the metrics.
## How it works?

## How it works
A bash script will get the env var when the container starts and replace the placeholders in the `prometheus.yml` file.

### Prometheus
Then, Prometheus will be started as usual.

Prometheus will collect the metrics from these sources:
- Orthanc ([link to official doc](https://book.orthanc-server.com/users/advanced-rest.html#instrumentation-with-prometheus))
- Node-exporter (allow to get the metrics from the system: CPU, RAM, disk space,...)
- Postgres (thanks to the exporter)
- CAdvisor (allow to get the metrics from the containers)

### Grafana
## How to use it ?

There is a predefined dashboard with all the metrics listed above.
Define these env vars:

## Misc
- There is a volume for the dashboard (Grafana container) so, if an update (with a new version of the dashboard) has to be made, the volume has to be deleted (otherwise, the dashboard will remain as it was)
- `DEPLOYMENT_NAME` (default: `unnamed_deployement`)
- `ORTHANC_SERVICE_NAME` (default: `orthanc`)
- `ORTHANC_SERVICE_PORT` (default: `8042`)
- `ORTHANC_USERNAME` (default: `orthanc`)
- `ORTHANC_PASSWORD` (default: `orthanc`)

- `REMOTE_WRITE_URL` (could be something like `https://prometheus-something.grafana.net/api/prom/push`)
- `REMOTE_WRITE_USERNAME` (some sort of ID from Grafana.com)
- `REMOTE_WRITE_PASSWORD` (can be generated from Grafana.com)
80 changes: 12 additions & 68 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3.8"
services:

orthanc:
image: osimis/orthanc:23.3.0
image: orthancteam/orthanc:24.3.4
restart: unless-stopped
depends_on:
- postgres
Expand All @@ -18,11 +18,16 @@ services:
ORTHANC__ORTHANC_EXPLORER_2__UI_OPTIONS__STUDY_LIST_SEARCH_MODE: "search-button"
ORTHANC__ORTHANC_EXPLORER_2__UI_OPTIONS__STUDY_LIST_EMPTY_IF_NO_SEARCH: "true"
ORTHANC__ORTHANC_EXPLORER_2__IS_DEFAULT_ORTHANC_UI: "true"
ORTHANC__ORTHANC_EXPLORER_2__DATE_FORMAT: "dd.MM.yyyy"
ORTHANC__POSTGRESQL__HOST: "postgres"
ORTHANC__POSTGRESQL__ENABLE_INDEX: "true"
ORTHANC__POSTGRESQL__ENABLE_STORAGE: "false"
DICOM_WEB_PLUGIN_ENABLED: "true"
ORTHANC__AUTHENTICATION_ENABLED: "false"
ORTHANC__AUTHENTICATION_ENABLED: "true"
ORTHANC__DICOM_MODALITIES: |
{
"test": ["test", "dicom-tls-relay", 50000]
}
volumes: ["orthanc-data:/var/lib/orthanc/db:Z"]

postgres:
Expand All @@ -38,77 +43,16 @@ services:
- 9090:9090
volumes:
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
restart: unless-stopped
depends_on:
- node-exporter

node-exporter:
image: prom/node-exporter:v1.5.0
ports:
- 9100:9100
# volumes:
# - /proc:/host/proc:ro
# - /sys:/host/sys:ro
# - /:/rootfs:ro
# command:
# - '--path.procfs=/host/proc'
# - '--path.sysfs=/host/sys'
# - '--collector.filesystem.ignored-mount-points=^/(dev|proc|sys|var/lib/docker/.+)($$|/)'
command:
- '--path.rootfs=/host'
# - '--cap-add=SYS_TIME'
volumes:
- '/:/host:ro,rslave'
# - /proc:/host/proc:ro
# - /sys:/host/sys:ro
# - /:/rootfs:ro
restart: unless-stopped

cadvisor:
image: gcr.io/cadvisor/cadvisor:v0.47.1
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
- /dev/disk/:/dev/disk:ro
privileged: true
restart: unless-stopped

postgres-exporter:
image: quay.io/prometheuscommunity/postgres-exporter:v0.12.0
restart: unless-stopped
depends_on:
- postgres
environment:
- DATA_SOURCE_NAME=postgresql://postgres@postgres:5432/postgres?sslmode=disable

grafana:
build: grafana
ports:
- 3000:3000
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_USERS_ALLOW_SIGN_UP=false
- DS_PROMETHEUS=prometheus
depends_on:
- prometheus
restart: unless-stopped
volumes:
- "dashboards:/var/lib/grafana:Z"
- "grafana-config:/etc/grafana:Z"
- "grafana-logs:/var/log/grafana:Z"
DEPLOYMENT_NAME: "test-name3"
env_file:
- ./prometheus.env




volumes:
prometheus_data:
orthanc-data:
orthanc-index:
dashboards:
grafana-config:
grafana-logs:


26 changes: 26 additions & 0 deletions old-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Orthanc-monitoring

WARNING: This folder contains some old setup which was used for testing/exploration.

## Summary
Here is only a basic Orthanc with a Postgres.

But these 2 services, as well as the host system and the containers, are monitored thanks to Prometheus.
Grafana is also there to show the metrics.

## How it works

### Prometheus

Prometheus will collect the metrics from these sources:
- Orthanc ([link to official doc](https://book.orthanc-server.com/users/advanced-rest.html#instrumentation-with-prometheus))
- Node-exporter (allow to get the metrics from the system: CPU, RAM, disk space,...)
- Postgres (thanks to the exporter)
- CAdvisor (allow to get the metrics from the containers)

### Grafana

There is a predefined dashboard with all the metrics listed above.

## Misc
- There is a volume for the dashboard (Grafana container) so, if an update (with a new version of the dashboard) has to be made, the volume has to be deleted (otherwise, the dashboard will remain as it was)
130 changes: 130 additions & 0 deletions old-tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
version: "3.8"

services:

orthanc:
image: orthancteam/orthanc:24.3.4
restart: unless-stopped
depends_on:
- postgres
ports:
- 8042:8042
environment:
ORTHANC__NAME: "Orthanc PACS"
VERBOSE_ENABLED: "true"
VERBOSE_STARTUP: "true"
STONE_WEB_VIEWER_PLUGIN_ENABLED: "true"
ORTHANC__STONE_WEB_VIEWER__SHOW_INFO_PANEL_AT_STARTUP: "Never"
ORTHANC__ORTHANC_EXPLORER_2__UI_OPTIONS__STUDY_LIST_SEARCH_MODE: "search-button"
ORTHANC__ORTHANC_EXPLORER_2__UI_OPTIONS__STUDY_LIST_EMPTY_IF_NO_SEARCH: "true"
ORTHANC__ORTHANC_EXPLORER_2__IS_DEFAULT_ORTHANC_UI: "true"
ORTHANC__ORTHANC_EXPLORER_2__DATE_FORMAT: "dd.MM.yyyy"
ORTHANC__POSTGRESQL__HOST: "postgres"
ORTHANC__POSTGRESQL__ENABLE_INDEX: "true"
ORTHANC__POSTGRESQL__ENABLE_STORAGE: "false"
DICOM_WEB_PLUGIN_ENABLED: "true"
ORTHANC__AUTHENTICATION_ENABLED: "true"
ORTHANC__DICOM_MODALITIES: |
{
"test": ["test", "dicom-tls-relay", 50000]
}
volumes: ["orthanc-data:/var/lib/orthanc/db:Z"]

postgres:
image: postgres:15
restart: unless-stopped
volumes: ["orthanc-index:/var/lib/postgresql/data:Z"]
environment:
POSTGRES_HOST_AUTH_METHOD: "trust"

prometheus:
build: prometheus
ports:
- 9090:9090
volumes:
- prometheus_data:/prometheus
restart: unless-stopped
environment:
REMOTE_WRITE_URL: "https://xxxxxx.grafana.net/api/prom/push"
REMOTE_WRITE_USERNAME: 000000

#DEPLOYMENT_NAME: "test-name3"

# node-exporter:
# image: prom/node-exporter:v1.5.0
# ports:
# - 9100:9100
# # volumes:
# # - /proc:/host/proc:ro
# # - /sys:/host/sys:ro
# # - /:/rootfs:ro
# # command:
# # - '--path.procfs=/host/proc'
# # - '--path.sysfs=/host/sys'
# # - '--collector.filesystem.ignored-mount-points=^/(dev|proc|sys|var/lib/docker/.+)($$|/)'
# command:
# - '--path.rootfs=/host'
# # - '--cap-add=SYS_TIME'
# volumes:
# - '/:/host:ro,rslave'
# # - /proc:/host/proc:ro
# # - /sys:/host/sys:ro
# # - /:/rootfs:ro
# restart: unless-stopped

# cadvisor:
# ports:
# - 8080:8080
# image: gcr.io/cadvisor/cadvisor:v0.47.1
# volumes:
# - /:/rootfs:ro
# - /var/run:/var/run:ro
# - /sys:/sys:ro
# - /var/lib/docker/:/var/lib/docker:ro
# - /dev/disk/:/dev/disk:ro
# privileged: true
# restart: unless-stopped

# postgres-exporter:
# ports:
# - 9187:9187
# image: quay.io/prometheuscommunity/postgres-exporter:v0.12.0
# restart: unless-stopped
# depends_on:
# - postgres
# environment:
# - DATA_SOURCE_NAME=postgresql://postgres@postgres:5432/postgres?sslmode=disable

grafana:
build: grafana
ports:
- 3000:3000
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_USERS_ALLOW_SIGN_UP=false
- DS_PROMETHEUS=prometheus
depends_on:
- prometheus
restart: unless-stopped
volumes:
- "dashboards:/var/lib/grafana:Z"
- "grafana-config:/etc/grafana:Z"
- "grafana-logs:/var/log/grafana:Z"


victoria-metrics:
image: victoriametrics/victoria-metrics:v1.94.0
ports:
- 8428:8428
volumes:
- ./vm-data/:/victoria-metrics-data

volumes:
prometheus_data:
orthanc-data:
orthanc-index:
dashboards:
grafana-config:
grafana-logs:

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions old-tests/prometheus/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM prom/prometheus:v2.51.1

COPY prometheus.yml /etc/prometheus/

CMD ["--config.file=/etc/prometheus/prometheus.yml", "--storage.tsdb.path=/prometheus", "--web.console.libraries=/usr/share/prometheus/console_libraries", "--web.console.templates=/usr/share/prometheus/consoles", "--enable-feature=expand-external-labels"]
Loading

0 comments on commit 592039a

Please sign in to comment.