Skip to content

Commit

Permalink
Clarify install instructions and update dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
rcowham committed Dec 7, 2020
1 parent 49deb78 commit 499c66c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 15 deletions.
56 changes: 47 additions & 9 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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
```
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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/<sdp_instance>/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
```

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
6 changes: 1 addition & 5 deletions p4prom.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 499c66c

Please sign in to comment.