Skip to content

Commit

Permalink
fix(no_token_errors): fix prometheus token errors
Browse files Browse the repository at this point in the history
* fix prometheus "no token" error

prometheus won't scrape metrics with labels containing unexpected characters
got the regex from https://github.com/prometheus/client_python/blob/3627472bd3257c1763f69e55e21612a5c8d6f49a/prometheus_client/metrics_core.py#L10

* fix CI tests

* Fix build and upgrade to 3.7 python

Co-authored-by: gmaurice <>
Co-authored-by: Daniel Pryor <daniel@pryorda.net>

Precommit-Verified: fafc5149cec54cf70b32aacaa01e26fcfe54cd5cf46ebc49b9ad0393e2c9d92b
  • Loading branch information
gmaurice authored and pryorda committed Oct 9, 2020
1 parent 8cb2284 commit 27a9202
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM python:3.6-alpine
FROM python:3.7-alpine

LABEL MAINTAINER="Daniel Pryor <daniel@pryorda.net>"
LABEL NAME=vmware_exporter

WORKDIR /opt/vmware_exporter/
COPY . /opt/vmware_exporter/

RUN set -x; buildDeps="gcc python-dev musl-dev libffi-dev openssl openssl-dev" \
RUN set -x; buildDeps="gcc python3-dev musl-dev libffi-dev openssl openssl-dev" \
&& apk add --no-cache --update $buildDeps \
&& pip install -r requirements.txt . \
&& apk del $buildDeps
Expand Down
2 changes: 2 additions & 0 deletions vmware_exporter/vmware_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Generic imports
import argparse
import os
import re
import ssl
import sys
import traceback
Expand Down Expand Up @@ -1150,6 +1151,7 @@ def updateMetricsLabelNames(self, metrics, metric_types):
metric._labelnames = labelnames[0:len(self._labelNames[metric_type])]
metric._labelnames += customAttributesLabelNames
metric._labelnames += labelnames[len(self._labelNames[metric_type]):]
metric._labelnames = list(map(lambda x: re.sub('[^a-zA-Z0-9_]', '_', x), metric._labelnames))

@defer.inlineCallbacks
def _vmware_get_datastores(self, ds_metrics):
Expand Down

0 comments on commit 27a9202

Please sign in to comment.