Skip to content

Commit c428648

Browse files
authored
Merge pull request #53 from genegr/master
Changed arrays token map semantic.
2 parents b9514d7 + 31dd27e commit c428648

File tree

11 files changed

+224
-108
lines changed

11 files changed

+224
-108
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ GOTEST=$(GOCMD) test
44
GOVET=$(GOCMD) vet
55
BINARY_NAME=pure-fa-om-exporter
66
MODULE_NAME=purestorage/fa-openmetrics-exporter
7-
VERSION?=1.0.5.hotfix2
7+
VERSION?=1.0.6
88
SERVICE_PORT?=9490
99
DOCKER_REGISTRY?= quay.io/purestorage/
1010
EXPORT_RESULT?=false # for CI please set EXPORT_RESULT to true

cmd/fa-om-exporter/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,18 @@ func metricsHandler(w http.ResponseWriter, r *http.Request) {
116116
authHeader := r.Header.Get("Authorization")
117117
authFields := strings.Fields(authHeader)
118118

119-
apitoken := arraytokens.GetApiToken(endpoint)
119+
address, apitoken := arraytokens.GetArrayParams(endpoint)
120120
if len(authFields) == 2 && strings.ToLower(authFields[0]) == "bearer" {
121121
apitoken = authFields[1]
122+
address = endpoint
122123
}
123124
if apitoken == "" {
124125
http.Error(w, "Target authorization token is missing", http.StatusBadRequest)
125126
return
126127
}
127128

128129
registry := prometheus.NewRegistry()
129-
faclient := client.NewRestClient(endpoint, apitoken, apiver, debug)
130+
faclient := client.NewRestClient(address, apitoken, apiver, debug)
130131
if faclient.Error != nil {
131132
http.Error(w, "Error connecting to FlashArray. Check your management endpoint and/or api token are correct.", http.StatusBadRequest)
132133
return
Lines changed: 48 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,50 @@
11
global:
2-
scrape_interval: 60s
3-
scrape_timeout: 50s
2+
scrape_interval: 60s
3+
scrape_timeout: 50s
4+
evaluation_interval: 30s
45
scrape_configs:
5-
- job_name: 'purestorage-fa'
6-
metrics_path: /metrics/array
7-
authorization:
8-
credentials: <YOUR_API_TOKEN>
9-
params:
10-
endpoint: [<YOUR_FLASHARRAY_IP>]
11-
12-
static_configs:
13-
- targets:
14-
- pure-fa-om-exporter:9490
15-
labels:
16-
location: US
17-
site: TestSite
18-
instance: FlashArray1
19-
env: 'Test Lab'
20-
21-
- job_name: 'purestorage-fa_volumes'
22-
metrics_path: /metrics/volumes
23-
authorization:
24-
credentials: <YOUR_API_TOKEN>
25-
params:
26-
endpoint: [<YOUR_FLASHARRAY_IP>]
27-
28-
static_configs:
29-
- targets:
30-
- pure-fa-om-exporter:9490
31-
labels:
32-
location: US
33-
site: TestSite
34-
instance: FlashArray1
35-
env: 'Test Lab'
36-
37-
- job_name: 'purestorage-fa_hosts'
38-
metrics_path: /metrics/hosts
39-
authorization:
40-
credentials: <YOUR_API_TOKEN>
41-
params:
42-
endpoint: [<YOUR_FLASHARRAY_IP>]
43-
44-
static_configs:
45-
- targets:
46-
- pure-fa-om-exporter:9490
47-
labels:
48-
location: US
49-
site: TestSite
50-
instance: FlashArray1
51-
env: 'Test Lab'
52-
53-
- job_name: 'purestorage-fa_pods'
54-
metrics_path: /metrics/pods
55-
authorization:
56-
credentials: <YOUR_API_TOKEN>
57-
params:
58-
endpoint: [<YOUR_FLASHARRAY_IP>]
59-
60-
static_configs:
61-
- targets:
62-
- pure-fa-om-exporter:9490
63-
labels:
64-
location: US
65-
site: TestSite
66-
instance: FlashArray1
67-
env: 'Test Lab'
68-
69-
- job_name: 'purestorage-fa_directories'
70-
metrics_path: /metrics/directories
71-
authorization:
72-
credentials: <YOUR_API_TOKEN>
73-
params:
74-
endpoint: [<YOUR_FLASHARRAY_IP>]
75-
76-
static_configs:
77-
- targets:
78-
- pure-fa-om-exporter:9490
79-
labels:
80-
location: US
81-
site: TestSite
82-
instance: FlashArray1
83-
env: 'Test Lab'
84-
6+
- job_name: monitoring/pure-fa-probe
7+
honor_timestamps: true
8+
scrape_interval: 30s
9+
scrape_timeout: 10s
10+
metrics_path: /metrics/array
11+
scheme: http
12+
follow_redirects: true
13+
enable_http2: true
14+
relabel_configs:
15+
- source_labels: [job]
16+
separator: ;
17+
regex: (.*)
18+
target_label: __tmp_prometheus_job_name
19+
replacement: $1
20+
action: replace
21+
- separator: ;
22+
regex: (.*)
23+
target_label: job
24+
replacement: pure-fa-probe
25+
action: replace
26+
- source_labels: [__address__]
27+
separator: ;
28+
regex: (.*)
29+
target_label: __param_endpoint
30+
replacement: $1
31+
action: replace
32+
- source_labels: [__param_endpoint]
33+
separator: ;
34+
regex: (.*)
35+
target_label: instance
36+
replacement: $1
37+
action: replace
38+
- separator: ;
39+
regex: (.*)
40+
target_label: __address__
41+
replacement: 10.225.113.63:9490
42+
action: replace
43+
static_configs:
44+
- targets:
45+
- x90a
46+
- x90b
47+
labels:
48+
env: Demo Lab
49+
location: UK
50+
site: Staines
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
app: pure-fa-ome
6+
name: pure-fa-ome
7+
namespace: observability-pure
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
app: pure-fa-ome
13+
template:
14+
metadata:
15+
labels:
16+
app: pure-fa-ome
17+
spec:
18+
containers:
19+
- command:
20+
- /pure-fa-om-exporter
21+
image: quay.io/purestorage/pure-fa-om-exporter:latest
22+
imagePullPolicy: Always
23+
name: pure-fa-om-exporter
24+
ports:
25+
- containerPort: 9490
26+
name: http-metrics
27+
protocol: TCP
28+
restartPolicy: Always
29+
30+
---
31+
32+
apiVersion: v1
33+
kind: Service
34+
metadata:
35+
labels:
36+
app: pure-fa-ome
37+
name: pure-fa-ome-svc
38+
namespace: observability-pure
39+
spec:
40+
ports:
41+
- name: http-metrics
42+
port: 9490
43+
protocol: TCP
44+
targetPort: 9490
45+
selector:
46+
app: pure-fa-ome

examples/config/k8s/operator/pure-fa-exporter-deployment.yaml renamed to examples/config/k8s/operator/pure-fa-ome-deploy_tokens.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4-
name: pure-fa-om-exporter
4+
name: pure-fa-ome
55
namespace: monitoring
66
labels:
77
app: pure-fa-exporter
@@ -22,7 +22,7 @@ spec:
2222
spec:
2323
containers:
2424
- name: pure-fa-om-exporter
25-
image: quay.io/purestorage/pure-fa-om-exporter/pure-fa-om-exporter:1.0.4
25+
image: quay.io/purestorage/pure-fa-om-exporter/pure-fa-om-exporter:latest
2626
command: ["/pure-fa-om-exporter"]
2727
imagePullPolicy: "Always"
2828
args:
@@ -33,7 +33,7 @@ spec:
3333
name: pure-fa-secret
3434
readOnly: true
3535
ports:
36-
- name: web
36+
- name: http-metrics
3737
containerPort: 9490
3838
restartPolicy: Always
3939
volumes:
@@ -46,13 +46,14 @@ spec:
4646
apiVersion: v1
4747
kind: Service
4848
metadata:
49-
name: pure-fa-exporter-svc
49+
name: pure-fa-ome-svc
5050
namespace: monitoring
5151
spec:
5252
ports:
5353
- port: 9490
5454
protocol: TCP
5555
targetPort: 9490
56+
name: http-metrics
5657
selector:
5758
app: pure-fa-exporter
5859
type: ClusterIP

examples/config/k8s/operator/pure-fa-probe.yaml renamed to examples/config/k8s/operator/pure-fa-probe_tokens.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ metadata:
66
spec:
77
jobName: pure-fa-probe
88
prober:
9-
url: pure-fa-exporter-svc:9490
10-
path: /metrics/pods
11-
interval: 15s
9+
url: pure-fa-ome-svc:9490
10+
path: /metrics/array
11+
interval: 60s
1212
targets:
1313
staticConfig:
1414
static:
15-
- 10.11.12.80
16-
- 10.11.12.82
17-
- 10.11.12.90
15+
- x90a
16+
- x90b
17+
- x70a
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
apiVersion: monitoring.coreos.com/v1
2+
kind: ServiceMonitor
3+
metadata:
4+
name: pure-fa-monitor
5+
namespace: observability-pure
6+
spec:
7+
jobLabel: pure-fa
8+
selector:
9+
matchLabels:
10+
app: pure-fa-ome
11+
namespaceSelector:
12+
matchNames:
13+
- observability-pure
14+
endpoints:
15+
- port: http-metrics
16+
interval: 60s
17+
path: /metrics/array
18+
bearerTokenSecret:
19+
name: x-90a-apitoken
20+
key: token
21+
params:
22+
endpoint:
23+
- 10.11.11.10
24+
relabelings:
25+
- replacement: z-x90a
26+
targetLabel: instance
27+
action: replace
28+
- replacement: Staines
29+
targetLabel: location
30+
action: replace
31+
- replacement: UK
32+
targetLabel: country
33+
action: replace
34+
- action: labeldrop
35+
regex: container|endpoint|job|namespace|pod|service
36+
- port: http-metrics
37+
interval: 60s
38+
path: /metrics/array
39+
bearerTokenSecret:
40+
name: x-90b-apitoken
41+
key: token
42+
params:
43+
endpoint:
44+
- 10.11.11.11
45+
relabelings:
46+
- action: replace
47+
replacement: z-x90b
48+
targetLabel: instance
49+
- replacement: UK
50+
targetLabel: country
51+
action: replace
52+
- replacement: Staines
53+
targetLabel: location
54+
action: replace
55+
- action: labeldrop
56+
regex: container|endpoint|job|namespace|pod|service
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
global:
2+
scrape_interval: 30s
3+
scrape_timeout: 10s
4+
evaluation_interval: 30s
5+
scrape_configs:
6+
- job_name: monitoring/pure-fa-probe
7+
honor_timestamps: true
8+
scrape_interval: 30s
9+
scrape_timeout: 10s
10+
metrics_path: /metrics/array
11+
scheme: http
12+
follow_redirects: true
13+
enable_http2: true
14+
relabel_configs:
15+
- source_labels: [job]
16+
separator: ;
17+
regex: (.*)
18+
target_label: __tmp_prometheus_job_name
19+
replacement: $1
20+
action: replace
21+
- separator: ;
22+
regex: (.*)
23+
target_label: job
24+
replacement: pure-fa-probe
25+
action: replace
26+
- source_labels: [__address__]
27+
separator: ;
28+
regex: (.*)
29+
target_label: __param_endpoint
30+
replacement: $1
31+
action: replace
32+
- source_labels: [__param_endpoint]
33+
separator: ;
34+
regex: (.*)
35+
target_label: instance
36+
replacement: $1
37+
action: replace
38+
- separator: ;
39+
regex: (.*)
40+
target_label: __address__
41+
replacement: 10.225.113.63:9490
42+
action: replace
43+
static_configs:
44+
- targets:
45+
- x90a
46+
- x90b
47+
- x70a
48+
labels:
49+
env: Demo Lab
50+
location: UK
51+
site: Staines

examples/config/k8s/simple-deployment/prometheus-configmap.yaml renamed to examples/config/k8s/simple-deployment/prometheus-configmap-simple.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ data:
1818
- targets:
1919
# - alertmanager:9093
2020
21-
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
22-
rule_files:
23-
# - "first_rules.yml"
24-
# - "second_rules.yml"
25-
2621
# A scrape configuration containing exactly one endpoint to scrape:
2722
scrape_configs:
2823
- job_name: 'purestorage-fa'

0 commit comments

Comments
 (0)