Bug 1894089

Summary: prometheus: no default configuration or systemd service
Product: [Fedora] Fedora Reporter: Dominik 'Rathann' Mierzejewski <dominik>
Component: golang-github-prometheusAssignee: Robert-André Mauchin 🐧 <eclipseo>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 32CC: eclipseo, go-sig
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: golang-github-prometheus-2.23.0-1.fc34 golang-github-prometheus-2.23.0-2.fc33 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-12-04 01:33:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dominik 'Rathann' Mierzejewski 2020-11-03 14:25:32 UTC
Description of problem:
Fedora-provided prometheus is not usable without manual configuration.
Please provide at least a default configuration (/etc/prometheus.yml) and a systemd unit file.

Comment 1 Dominik 'Rathann' Mierzejewski 2020-11-03 14:45:27 UTC
Suggestion:
# cat /usr/lib/systemd/system/prometheus.service 
[Unit]
Description=Prometheus instance
Documentation=https://prometheus.io/docs/prometheus/
Wants=network-online.target
After=network-online.target

[Service]
EnvironmentFile=/etc/sysconfig/prometheus
User=prometheus
Group=prometheus
Type=simple
WorkingDirectory=/var/lib/prometheus
ExecStart=/usr/bin/prometheus \
          --config.file=${CONFIG_FILE} \
          --storage.tsdb.path=${STORAGE_TSDB_PATH} \
          --web.console.libraries=${WEB_CONSOLE_LIBRARIES_PATH} \
          --web.console.templates=${WEB_CONSOLE_TEMPLATES_PATH} \
          --web.listen-address=${WEB_LISTEN_ADDRESS}

[Install]
WantedBy=multi-user.target

# cat /etc/sysconfig/prometheus 
CONFIG_FILE=/etc/prometheus.yml
STORAGE_TSDB_PATH=/var/lib/prometheus
WEB_CONSOLE_LIBRARIES_PATH=/usr/share/prometheus/console_libraries
WEB_CONSOLE_TEMPLATES_PATH=/usr/share/prometheus/consoles
WEB_LISTEN_ADDRESS=127.0.0.1:9090 

# cat /etc/prometheus.yml 
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']

Also, add empty /var/lib/prometheus, /usr/share/prometheus/console_libraries, /usr/share/prometheus/consoles to the package and create the prometheus user+group via systemd-sysusers.

Comment 2 Dominik 'Rathann' Mierzejewski 2020-11-03 15:08:47 UTC
$ prometheus --version
prometheus, version  (branch: , revision: )
  build user:       
  build date:       
  go version:       go1.14beta1

I would expect those to be filled with actual build version and date (and perhaps the mockbuild user).

Comment 3 Robert-André Mauchin 🐧 2020-11-08 09:31:46 UTC
Go SIG doesn't really "take care" of the binaries provided, we mostly need the libraries to build stuff, but we don't often have the expertise to know all the various config.


(In reply to Dominik 'Rathann' Mierzejewski from comment #2)
> $ prometheus --version
> prometheus, version  (branch: , revision: )
>   build user:       
>   build date:       
>   go version:       go1.14beta1
> 
> I would expect those to be filled with actual build version and date (and
> perhaps the mockbuild user).


I need to set these ldflags:

    ldflags: |
        -X github.com/prometheus/common/version.Version={{.Version}}
        -X github.com/prometheus/common/version.Revision={{.Revision}}
        -X github.com/prometheus/common/version.Branch={{.Branch}}
        -X github.com/prometheus/common/version.BuildUser={{user}}@{{host}}
        -X github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}}

(In reply to Dominik 'Rathann' Mierzejewski from comment #1)
> Suggestion:
> # cat /usr/lib/systemd/system/prometheus.service 
> [Unit]
> Description=Prometheus instance
> Documentation=https://prometheus.io/docs/prometheus/
> Wants=network-online.target
> After=network-online.target
> 
> [Service]
> EnvironmentFile=/etc/sysconfig/prometheus
> User=prometheus
> Group=prometheus
> Type=simple
> WorkingDirectory=/var/lib/prometheus
> ExecStart=/usr/bin/prometheus \
>           --config.file=${CONFIG_FILE} \
>           --storage.tsdb.path=${STORAGE_TSDB_PATH} \
>           --web.console.libraries=${WEB_CONSOLE_LIBRARIES_PATH} \
>           --web.console.templates=${WEB_CONSOLE_TEMPLATES_PATH} \
>           --web.listen-address=${WEB_LISTEN_ADDRESS}
> 
> [Install]
> WantedBy=multi-user.target
> 
> # cat /etc/sysconfig/prometheus 
> CONFIG_FILE=/etc/prometheus.yml
> STORAGE_TSDB_PATH=/var/lib/prometheus
> WEB_CONSOLE_LIBRARIES_PATH=/usr/share/prometheus/console_libraries
> WEB_CONSOLE_TEMPLATES_PATH=/usr/share/prometheus/consoles
> WEB_LISTEN_ADDRESS=127.0.0.1:9090 
> 
> # cat /etc/prometheus.yml 
> # A scrape configuration containing exactly one endpoint to scrape:
> # Here it's Prometheus itself.
> scrape_configs:
>   # The job name is added as a label `job=<job_name>` to any timeseries
> scraped from this config.
>   - job_name: 'prometheus'
> 
>     # metrics_path defaults to '/metrics'
>     # scheme defaults to 'http'.
> 
>     static_configs:
>     - targets: ['localhost:9090']
> 

OK

> Also, add empty /var/lib/prometheus,
> /usr/share/prometheus/console_libraries, /usr/share/prometheus/consoles to
> the package and create the prometheus user+group via systemd-sysusers.

/var/lib/prometheus should be owned by prometheus user right?
I'm not familiar with systemd-sysusers, usually we use shadow-utils for user creation: https://docs.fedoraproject.org/en-US/packaging-guidelines/UsersAndGroups/

Comment 4 Robert-André Mauchin 🐧 2020-11-08 10:00:25 UTC
This is my prometheus conf:

#Type Name       ID                  GECOS              Home directory
u     prometheus  -                  Prometheus         /var/lib/prometheus
g     prometheus  -
m     prometheus  prometheus
r     -           500-900

According to the systemd macros, it should be installed as such:

%pre
%sysusers_create_package prometheus %{SOURCE4}

Everything looks alright to you?

Comment 5 Robert-André Mauchin 🐧 2020-11-08 10:56:48 UTC
Please check this PR to see if it suits you:
https://src.fedoraproject.org/rpms/golang-github-prometheus/pull-request/1#request_diff

Comment 6 Dominik 'Rathann' Mierzejewski 2020-12-03 11:48:12 UTC
Looks good to me, but I'm no expert. Requested review on the Fedora Server mailing list: https://lists.fedoraproject.org/archives/list/server@lists.fedoraproject.org/message/BQSKW5UDFJ54ZZ5OUT7JNHZ5F2NTTNY2/ .

Comment 7 Robert-André Mauchin 🐧 2020-12-03 20:51:40 UTC
Apparently it was missing the web assets for the frontend toov

Comment 8 Fedora Update System 2020-12-04 01:33:34 UTC
FEDORA-2020-a116217589 has been pushed to the Fedora 34 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 9 Fedora Update System 2020-12-04 02:16:27 UTC
FEDORA-2020-9ea1ff01f8 has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2020-9ea1ff01f8

Comment 10 Fedora Update System 2020-12-05 01:59:28 UTC
FEDORA-2020-9ea1ff01f8 has been pushed to the Fedora 33 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-9ea1ff01f8`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-9ea1ff01f8

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 11 Fedora Update System 2020-12-06 07:17:14 UTC
FEDORA-2020-8e8039d97c has been pushed to the Fedora 33 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-8e8039d97c`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-8e8039d97c

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 12 Fedora Update System 2020-12-14 00:58:53 UTC
FEDORA-2020-8e8039d97c has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.