-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Grafana/Prometheus/TimescaleSB image
- Loading branch information
1 parent
537ac00
commit e1c3ea5
Showing
10 changed files
with
1,702 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2019 Jesper Pedersen <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the "Software"), | ||
# to deal in the Software without restriction, including without limitation | ||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
# and/or sell copies of the Software, and to permit persons to whom the Software | ||
# is furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
# | ||
# pgsql11-grafana-centos7 | ||
FROM centos:centos7 | ||
|
||
LABEL maintainer="Jesper Pedersen <[email protected]>" | ||
|
||
LABEL summary="PostgreSQL 11 Grafana" \ | ||
description="PostgreSQL 11 Grafana" | ||
|
||
# COPY conf/licenses /licenses | ||
|
||
ENV PGVERSION="11" | ||
ENV PGROOT="/usr/pgsql-${PGVERSION}" | ||
|
||
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \ | ||
&& rpm -Uvh https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm \ | ||
&& yum -y install centos-release-scl-rh \ | ||
&& yum -y install wget tar git gcc llvm5.0 llvm5.0-static make \ | ||
&& yum -y install devtoolset-7 llvm-toolset-7 \ | ||
&& yum -y update \ | ||
&& yum -y install postgresql11 postgresql11-server postgresql11-devel postgresql11-contrib postgresql11-libs \ | ||
&& yum install -y timescaledb_11 \ | ||
&& yum -y clean all | ||
|
||
COPY root/ / | ||
|
||
RUN mkdir -p /conf /pgconf /pgdata /pgwal | ||
COPY conf/* /conf/ | ||
RUN chown -R postgres:postgres /conf /pgconf /pgdata /pgwal | ||
RUN chmod 700 /conf /pgconf /pgdata /pgwal | ||
|
||
RUN cd /tmp \ | ||
&& git clone https://github.com/timescale/pg_prometheus.git \ | ||
&& cd pg_prometheus \ | ||
&& export PATH=/usr/pgsql-11/bin:$PATH \ | ||
&& make \ | ||
&& make install \ | ||
&& cd .. \ | ||
&& rm -Rf pg_prometheus | ||
|
||
RUN cd /tmp \ | ||
&& wget https://github.com/timescale/prometheus-postgresql-adapter/releases/download/0.4.1/prometheus-postgresql-adapter-0.4.1-linux-amd64.tar.gz \ | ||
&& tar xzf prometheus-postgresql-adapter-0.4.1-linux-amd64.tar.gz \ | ||
&& mv prometheus-postgresql-adapter /usr/local/bin/prometheus-postgresql-adapter \ | ||
&& rm -Rf prometheus-postgresql-adapter-0.4.1-linux-amd64.tar.gz \ | ||
&& chown postgres:postgres /usr/local/bin/prometheus-postgresql-adapter | ||
|
||
RUN cd /tmp \ | ||
&& wget https://github.com/prometheus/prometheus/releases/download/v2.9.2/prometheus-2.9.2.linux-amd64.tar.gz \ | ||
&& mkdir -p /usr/local/ \ | ||
&& cd /usr/local \ | ||
&& tar xzf /tmp/prometheus-2.9.2.linux-amd64.tar.gz \ | ||
&& mv prometheus-2.9.2.linux-amd64 prometheus \ | ||
&& chown -R postgres:postgres prometheus \ | ||
&& rm -Rf /tmp/prometheus-2.9.2.linux-amd64.tar.gz | ||
|
||
RUN cd /tmp \ | ||
&& wget https://dl.grafana.com/oss/release/grafana-6.2.0.linux-amd64.tar.gz \ | ||
&& mkdir -p /usr/local/ \ | ||
&& cd /usr/local \ | ||
&& tar xzf /tmp/grafana-6.2.0.linux-amd64.tar.gz \ | ||
&& mv grafana-6.2.0 grafana \ | ||
&& chown -R postgres:postgres grafana \ | ||
&& rm -Rf /tmp/grafana-6.2.0.linux-amd64.tar.gz | ||
|
||
VOLUME ["/pgconf", "/pgdata", "/pgwal"] | ||
|
||
EXPOSE 9090 | ||
EXPOSE 3000 | ||
|
||
USER 26 | ||
|
||
CMD ["/usr/bin/run-grafana"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2019 Jesper Pedersen <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the "Software"), | ||
# to deal in the Software without restriction, including without limitation | ||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
# and/or sell copies of the Software, and to permit persons to whom the Software | ||
# is furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
# | ||
IMAGE_NAME = pgsql11-grafana-centos7 | ||
|
||
.PHONY: build | ||
build: | ||
podman build --no-cache -t $(IMAGE_NAME) . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# PostgreSQL Grafana | ||
|
||
This project contains the PostgreSQL Grafana/Prometheus/TimescaleDB image. | ||
|
||
## Getting Started | ||
|
||
```bash | ||
# Create the image | ||
make build | ||
|
||
# Run, and register the container under postgresql-grafana | ||
podman run -p 9090:9090 -p 3000:3000 --name postgresql-grafana -d -e PG_USER_NAME=monuser -e PG_USER_PASSWORD=monpass -e PG_NETWORK_MASK=all -e PG_MONITOR1=192.168.1.2:9100 -e PG_MONITOR2=192.168.1.2:9187 pgsql11-grafana-centos7 | ||
|
||
# Shell to postgresql-grafana | ||
podman exec -it postgresql-grafana /usr/bin/bash | ||
|
||
# Get the IP address of the postgresql-grafana container | ||
podman inspect postgresql-grafana | grep IPAddress | ||
|
||
# Stop the container | ||
podman stop postgresql-grafana | ||
|
||
# Start the container | ||
podman start postgresql-grafana | ||
|
||
# Remove the container | ||
podman rm postgresql-grafana | ||
``` | ||
|
||
## Configuration | ||
|
||
| Property | Default | Unit | Required | Description | | ||
|----------|---------|------|----------|-------------| | ||
| PG_USER_NAME | | | Yes | The user name | | ||
| PG_USER_PASSWORD | | | Yes | The password for the user | | ||
| PG_NETWORK_MASK | | | Yes | The network mask for database access | | ||
| PG_MAX_CONNECTIONS | 100 | | | `max_connections` setting | | ||
| PG_SHARED_BUFFERS | 256 | MB | | `shared_buffers` setting | | ||
| PG_WORK_MEM | 8 | MB | | `work_mem` setting | | ||
| PG_MAX_PARALLEL_WORKERS | 8 | | | `max_parallel_workers` setting | | ||
| PG_EFFECTIVE_CACHE_SIZE | 1 | GB | | `effective_cache_size` setting | | ||
| PG_MAX_WAL_SIZE | 1 | GB | | `max_wal_size` setting | | ||
| PG_MONITOR1 | | | Yes | The first monitoring point | | ||
| PG_MONITOR2 | | | | The second monitoring point | | ||
| PG_MONITOR3 | | | | The third monitoring point | | ||
| PG_MONITOR4 | | | | The fourth monitoring point | | ||
|
||
## Volumes | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| `/pgconf` | Volume for SSL configuration | | ||
| `/pgdata` | PostgreSQL data directory | | ||
| `/pgwal` | PostgreSQL Write-Ahead Log (WAL) | | ||
|
||
## SSL support | ||
|
||
SSL support will be enabled when `/pgconf` contains the files `root.crt`, `server.crt` and `server.key`. | ||
|
||
Remember to disable passphase such that the server can boot without a password prompt. | ||
|
||
A guide to this can be found [here](https://www.howtoforge.com/postgresql-ssl-certificates). | ||
Test and production environments should **NOT** be using self-signed certificates. |
Oops, something went wrong.