From 499c66cde49a8e4e871510945ec05ddd802dc7fa Mon Sep 17 00:00:00 2001 From: Robert Cowham Date: Mon, 7 Dec 2020 17:33:19 +0000 Subject: [PATCH] Clarify install instructions and update dependency --- INSTALL.md | 56 +++++++++++++++++++++++++++++++++++++++++++++--------- go.mod | 2 +- go.sum | 2 ++ p4prom.go | 6 +----- 4 files changed, 51 insertions(+), 15 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index a48c82d..7532b86 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,7 +1,5 @@ # Installation Details for P4Prometheus and Other Components -Decide if you want to install via packages/manually or using [Ansible Installation](#ansible-installation). - Note it is possible to perform [Windows Installation](#windows-installation). On monitoring server, install: @@ -25,6 +23,7 @@ On your commit/master or any perforce edge/replica servers, install: - [Install Prometheus](#install-prometheus) - [Prometheus config](#prometheus-config) - [Install victoria metrics (optional but recommended)](#install-victoria-metrics-optional-but-recommended) + - [Substituting VictoriMetrics for Prometheus in Grafana](#substituting-victorimetrics-for-prometheus-in-grafana) - [Importing Prometheus data into Victoria Metrics](#importing-prometheus-data-into-victoria-metrics) - [Install node exporter](#install-node-exporter) - [Install p4prometheus - details](#install-p4prometheus---details) @@ -155,8 +154,11 @@ scrape_configs: - job_name: 'node_exporter' static_configs: - # CONFIGURE THESE VALUES FOR YOUR SERVERS!!!! - - targets: ['p4hms:9100', 'p4main:9100', 'p4_ha:9100'] + # CONFIGURE THESE VALUES AS APPROPRIATE FOR YOUR SERVERS!!!! + - targets: + - p4hms:9100 + - p4main:9100 + - p4_ha:9100 EOF ``` @@ -203,13 +205,15 @@ Group=prometheus Type=simple ExecStart=/usr/local/bin/victoria-metrics-prod \ -storageDataPath /var/lib/victoria-metrics/ \ - -retentionPeriod=3 + -retentionPeriod=6 [Install] WantedBy=multi-user.target EOF ``` +Consider adjusting the `retentionPeriod` vale in the config file. + Ensure data directory exists and is properly owned: sudo mkdir /var/lib/victoria-metrics @@ -239,6 +243,13 @@ Either start or restart Prometheus: sudo systemctl restart prometheus +#### Substituting VictoriMetrics for Prometheus in Grafana + +If using VictoriaMetrics, then you should: + +* Create a suitable data source in Grafana (e.g. `http://localhost:8428`) +* Change existing dashboards to use it instead of Prometheus (it is API compatible) + ### Importing Prometheus data into Victoria Metrics This can be fairly easily done, and will allow you to save the space used by Prometheus. @@ -316,7 +327,7 @@ Get latest release download link: https://github.com/perforce/p4prometheus/relea Run the following as `root` (using link copied from above page): - export PVER=0.6.0 + export PVER=0.7.0 wget https://github.com/perforce/p4prometheus/releases/download/v$PVER/p4prometheus.linux-amd64.gz gunzip p4prometheus.linux-amd64.gz @@ -331,27 +342,54 @@ Important to check configuration values, e.g. `log_path`, `metrics_output` etc. ```bash cat << EOF > /p4/common/config/p4prometheus.yaml +# ---------------------- # sdp_instance: SDP instance - typically integer, but can be # See: https://swarm.workshop.perforce.com/projects/perforce-software-sdp for more # If this value is blank then it is assumed to be a non-SDP instance. sdp_instance: 1 -# log_path: Path to p4d server log + +# ---------------------- +# log_path: Path to p4d server log - REQUIRED! log_path: /p4/1/logs/log + +# ---------------------- # metrics_output: Name of output file to write for processing by node_exporter. # Ensure that node_exporter user has read access to this folder. metrics_output: /hxlogs/metrics/p4_cmds.prom + +# ---------------------- # server_id: Optional - serverid for metrics - typically read from /p4//root/server.id for # SDP installations - please specify a value if non-SDP install server_id: -# output_cmds_by_user: Whether to output metrics p4_cmd_user_counter/p4_cmd_user_cumulative_seconds + +# ---------------------- +# output_cmds_by_user: true/false - Whether to output metrics p4_cmd_user_counter/p4_cmd_user_cumulative_seconds # Normally this should be set to true as the metrics are useful. # If you have a p4d instance with thousands of users you may find the number # of metrics labels is too great (one per distinct user), so set this to false. output_cmds_by_user: true -# case_sensitive_server: if output_cmds_by_user=true then if this value is set to false + +# ---------------------- +# case_sensitive_server: true/false - if output_cmds_by_user=true then if this value is set to false # all userids will be written in lowercase - otherwise as they occur in the log file # If not present, this value will default to true on Windows and false otherwise. case_sensitive_server: true + +# ---------------------- +# output_cmds_by_ip: true/false - Whether to output metrics p4_cmd_ip_counter/p4_cmd_ip_cumulative_seconds +# Like output_cmds_by_user this can be an issue for larger sites so defaults to false. +output_cmds_by_ip: true + +# ---------------------- +# output_cmds_by_user_regex: Specifies a Go regex for users for whom to output +# metrics p4_cmd_user_detail_counter (tracks cmd counts per user/per cmd) and +# p4_cmd_user_detail_cumulative_seconds +# +# This can be set to values such as: "" (no users), ".*" (all users), or "swarm|jenkins" +# for just those 2 users. The latter is likely to be appropriate in many sites (keep an eye +# on automation users only, without generating thousands of labels for all users) +output_cmds_by_user_regex: "" + EOF ``` diff --git a/go.mod b/go.mod index 11b1516..f0969ea 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.14 require ( github.com/alecthomas/units v0.0.0-20201120081800-1786d5ef83d4 // indirect github.com/prometheus/common v0.15.0 // indirect - github.com/rcowham/go-libp4dlog v0.9.3 + github.com/rcowham/go-libp4dlog v0.9.4 github.com/rcowham/go-libtail v0.1.0 github.com/sirupsen/logrus v1.7.0 github.com/stretchr/testify v1.6.1 diff --git a/go.sum b/go.sum index 26a599c..0f9a704 100644 --- a/go.sum +++ b/go.sum @@ -246,6 +246,8 @@ github.com/rcowham/go-libp4dlog v0.9.2 h1:0OwtLqMY+qL4wyLg4G+1AH0xilo2YJRPFopjIE github.com/rcowham/go-libp4dlog v0.9.2/go.mod h1:un2Mss+FGxti6HfAgZqiH7qPo2iMLwwDDP+1ZvvkqZA= github.com/rcowham/go-libp4dlog v0.9.3 h1:T8ZnYdTtZFgHaAhhKHj6DaM95pJyIdU0zIs8+F01RMQ= github.com/rcowham/go-libp4dlog v0.9.3/go.mod h1:un2Mss+FGxti6HfAgZqiH7qPo2iMLwwDDP+1ZvvkqZA= +github.com/rcowham/go-libp4dlog v0.9.4 h1:s7HeTsTlUGgQu8KnGrJz3HZ6YNtcpWNs66Jlt+UlG2Q= +github.com/rcowham/go-libp4dlog v0.9.4/go.mod h1:un2Mss+FGxti6HfAgZqiH7qPo2iMLwwDDP+1ZvvkqZA= github.com/rcowham/go-libtail v0.1.0 h1:VdN2YbVUXNMKoORZ3u/vVW0iUY07tzrrdZTOpyhEr54= github.com/rcowham/go-libtail v0.1.0/go.mod h1:+DkaEGPlgLKzIv26Br8l1Xd36GK52ENBZ8DIDTS/2HQ= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= diff --git a/p4prom.go b/p4prom.go index fbac6e0..457953c 100644 --- a/p4prom.go +++ b/p4prom.go @@ -141,11 +141,7 @@ func runLogTailer(logger *logrus.Logger, logcfg *logConfig, cfg *config.Config, OutputCmdsByIP: cfg.OutputCmdsByIP, CaseSensitiveServer: cfg.CaseSensitiveServer, } - logger.Infof("P4Prometheus config: debug %v, serverID %s, SDPInstance %s, UpdateInterval %s, OutputCmdsByUser %v, OutputCmdsByUserRegex '%s', OutputCmdsByIP %v, CaseSenstiveServer %v", - mcfg.Debug, mcfg.ServerID, mcfg.SDPInstance, mcfg.UpdateInterval, - mcfg.OutputCmdsByUser, mcfg.OutputCmdsByUserRegex, mcfg.OutputCmdsByIP, - mcfg.CaseSensitiveServer) - logger.Infof("P4Prometheus config2: %v", mcfg) + logger.Infof("P4Prometheus config: %+v", mcfg) mp := metrics.NewP4DMetricsLogParser(mcfg, logger, false) linesChan := make(chan string, 10000)