Skip to content

Commit

Permalink
docker/snap changes
Browse files Browse the repository at this point in the history
  • Loading branch information
albertodonato committed Dec 27, 2024
1 parent af0f5ae commit 52674c4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 49 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ COPY --from=build-image /opt /opt
ENV PATH="/virtualenv/bin:$PATH"
ENV VIRTUAL_ENV="/virtualenv"
ENV LD_LIBRARY_PATH="/opt/oracle/instantclient"
# IPv6 support is not enabled by default, only bind IPv4
ENV QE_HOST="0.0.0.0"

EXPOSE 9560/tcp
VOLUME /config
# IPv6 support is not enabled by default, only bind IPv4
ENTRYPOINT ["query-exporter", "/config/config.yaml", "-H", "0.0.0.0"]
WORKDIR /config
ENTRYPOINT ["query-exporter"]
34 changes: 23 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ Each query can be run on multiple databases, and update multiple metrics.

The application is simply run as::

query-exporter config.yaml
query-exporter

where the passed configuration file contains the definitions of the databases
to connect and queries to perform to update metrics.
which will look for a ``config.yaml`` configuration file in the current
directory, containing the definitions of the databases to connect and queries
to perform to update metrics. The configuration file can be overridden by
passing the ``--config`` option, or setting the ``QE_CONFIG`` environment
variable.


Configuration file format
Expand Down Expand Up @@ -504,8 +507,9 @@ included by passing ``--process-stats`` in the command line.
Debugging / Logs
----------------

You can enable extended logging using the ``-L`` commandline switch. Possible
log levels are ``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO``, ``DEBUG``.
You can enable extended logging using the ``-L`` (or ``-log-level``) command
line switch. Possible log levels are ``critical``, ``error``, ``warning``,
``info``, ``debug``.


Database engines
Expand Down Expand Up @@ -539,6 +543,8 @@ To configure the daemon:

- create or edit ``/var/snap/query-exporter/current/config.yaml`` with the
configuration
- optionally, create a ``/var/snap/query-exporter/current/.env`` file with
environment variables definitions for additional config options
- run ``sudo snap restart query-exporter``

The snap has support for connecting the following databases:
Expand All @@ -563,12 +569,10 @@ where ``$CONFIG_DIR`` is the absolute path of a directory containing a
``config.yaml`` file, the configuration file to use. Alternatively, a volume
name can be specified.


A different ODBC driver version to use can be specified during image building,
by passing ``--build-arg ODBC_bVERSION_NUMBER``, e.g.::

docker build . --build-arg ODBC_DRIVER_VERSION=17

If, a ``.env`` file is present in the specified volume for ``/config``, its
content is loaded and applied to the environment for the exporter. The location
of the dotenv file can be customized by setting the ``QE_DOTENV`` environment
variable.

The image has support for connecting the following databases:

Expand All @@ -582,6 +586,14 @@ The image has support for connecting the following databases:

A `Helm chart`_ to run the container in Kubernetes is also available.

ODBC driver version
~~~~~~~~~~~~~~~~~~~

A different ODBC driver version to use can be specified during image building,
by passing ``--build-arg ODBC_bVERSION_NUMBER``, e.g.::

docker build . --build-arg ODBC_DRIVER_VERSION=17


.. _Prometheus: https://prometheus.io/
.. _SQLAlchemy: https://www.sqlalchemy.org/
Expand Down
6 changes: 2 additions & 4 deletions snap/local/daemon.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/sh -e

CONFIG_FILE="$SNAP_DATA/config.yaml"
[ -r "$SNAP_DATA/config.yaml" ] || snapctl stop "$SNAP_INSTANCE_NAME"

[ -r "$CONFIG_FILE" ] || snapctl stop "$SNAP_INSTANCE_NAME"

exec "$SNAP/bin/query-exporter" -H 0.0.0.0 :: -- "$CONFIG_FILE"
exec env -C "$SNAP_DATA" "$SNAP/bin/query-exporter" --
32 changes: 0 additions & 32 deletions snap/local/query-exporter.completion

This file was deleted.

6 changes: 6 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ description: |
- create or edit `/var/snap/query-exporter/current/config.yaml` with the
configuration
- optionally, create a `/var/snap/query-exporter/current/.env` file with
environment variables definitions for additional config options
- run `sudo snap restart query-exporter`
Currently supported databases are:
Expand Down Expand Up @@ -83,12 +85,16 @@ parts:
- libodbc2
- libpq5
- libxml2
override-build: |
craftctl default
_QUERY_EXPORTER_COMPLETE=bash_source query-exporter > "$CRAFT_PART_INSTALL/query-exporter.completion"
prime:
- bin/python3
- bin/query-exporter
- etc
- lib
- pyvenv.cfg
- query-exporter.completion
- usr/lib

wrappers:
Expand Down

0 comments on commit 52674c4

Please sign in to comment.