Skip to content

Commit a2a39f9

Browse files
committed
Fix getting started guide
- Update to Cortex v1.17.1 - Configure Seaweedfs auth (uploads were failing otherwise) - Add some experiments to play with Cortex - Automate Grafana datasource creation - Remove Grafana auth to speed up getting started - Set scrape interval to 15s in K8s for more data Signed-off-by: Charlie Le <[email protected]>
1 parent e47ad33 commit a2a39f9

File tree

10 files changed

+154
-58
lines changed

10 files changed

+154
-58
lines changed

docs/getting-started/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORTEX_VERSION=v1.17.0
1+
CORTEX_VERSION=v1.17.1
22
GRAFANA_VERSION=10.4.2
33
PROMETHEUS_VERSION=v2.51.2
44
SEAWEEDFS_VERSION=3.67

docs/getting-started/_index.md

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,27 @@ how this is configured.
5757

5858
```sh
5959
# Create a bucket in SeaweedFS
60-
curl -X PUT http://localhost:8333/cortex-bucket
60+
curl --aws-sigv4 "aws:amz:local:seaweedfs" --user "any:any" -X PUT http://localhost:8333/cortex-bucket
6161
```
6262

63-
#### Configure Grafana
63+
#### Explore
6464

65-
1. Log into the Grafana instance at [http://localhost:3000](http://localhost:3000)
66-
* login credentials are `username: admin` and `password: admin`
67-
* There may be an additional screen on setting a new password. This can be skipped and is optional
68-
1. Navigate to the `Data Sources` page
69-
* Look for a gear icon on the left sidebar and select `Data Sources`
70-
1. Add a new Prometheus Data Source
71-
* Use `http://cortex:9009/api/prom` as the URL
72-
* Click `Save & Test`
73-
1. Go to `Metrics Explore` to query metrics
74-
* Look for a compass icon on the left sidebar
75-
* Click `Metrics` for a dropdown list of all the available metrics
65+
Grafana is configured to use Cortex as a data source. You can explore the data source in Grafana and query metrics. For example, this [explore](http://localhost:3000/explore?schemaVersion=1&panes=%7B%22au0%22:%7B%22datasource%22:%22P6693426190CB2316%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22rate%28prometheus_remote_storage_samples_total%5B$__rate_interval%5D%29%22,%22range%22:true,%22instant%22:true,%22datasource%22:%7B%22type%22:%22prometheus%22,%22uid%22:%22P6693426190CB2316%22%7D,%22editorMode%22:%22builder%22,%22legendFormat%22:%22__auto%22,%22useBackend%22:false,%22disableTextWrap%22:false,%22fullMetaSearch%22:false,%22includeNullMetadata%22:false%7D%5D,%22range%22:%7B%22from%22:%22now-1h%22,%22to%22:%22now%22%7D%7D%7D&orgId=1) page is showing the rate of samples being sent to Cortex.
7666

7767
If everything is working correctly, then the metrics seen in Grafana were successfully sent from Prometheus to Cortex
78-
via remote_write!
68+
via `remote_write`!
69+
70+
Other things to explore:
71+
72+
- [Cortex](http://localhost:9009) - Administrative interface for Cortex
73+
- Try shutting down the [ingester](http://localhost:9009/ingester/shutdown) and see how it affects metric ingestion.
74+
- Restart Cortex to bring the ingester back online, and see how Prometheus catches up.
75+
- Does it affect the querying of metrics in Grafana?
76+
- [Prometheus](http://localhost:9090) - Prometheus instance that is sending metrics to Cortex
77+
- Try querying the metrics in Prometheus.
78+
- Are they the same as what you see in Cortex?
79+
- [Grafana](http://localhost:3000) - Grafana instance that is visualizing the metrics.
80+
- Try creating a new dashboard and adding a new panel with a query to Cortex.
7981

8082
### Clean up
8183

@@ -140,55 +142,74 @@ $ kubectl -n cortex port-forward svc/seaweedfs 8333
140142

141143
```shell
142144
# Create a bucket
143-
$ curl -X PUT http://localhost:8333/cortex-bucket
145+
$ curl --aws-sigv4 "aws:amz:local:seaweedfs" --user "any:any" -X PUT http://localhost:8333/cortex-bucket
144146
```
145147

146148
#### Setup Cortex
147149

148150
```sh
149151
# Deploy Cortex using the provided values file which configures
150152
# - blocks storage to use the seaweedfs service
151-
$ helm install --version=2.3.0 --namespace cortex cortex cortex-helm/cortex -f cortex-values.yaml
153+
$ helm upgrade --install --version=2.3.0 --namespace cortex cortex cortex-helm/cortex -f cortex-values.yaml
152154
```
153155

154156
#### Setup Prometheus
155157

156158
```sh
157159
# Deploy Prometheus to scrape metrics in the cluster and send them, via remote_write, to Cortex.
158-
$ helm install --version=25.20.1 --namespace cortex prometheus prometheus-community/prometheus -f prometheus-values.yaml
160+
$ helm upgrade --install --version=25.20.1 --namespace cortex prometheus prometheus-community/prometheus -f prometheus-values.yaml
159161
```
160162

161163
#### Setup Grafana
162164

163165
```sh
164166
# Deploy Grafana to visualize the metrics that were sent to Cortex.
165-
$ helm install --version=7.3.9 --namespace cortex grafana grafana/grafana
167+
$ helm upgrade --install --version=7.3.9 --namespace cortex grafana grafana/grafana -f grafana-values.yaml
166168
```
167169

168-
#### Configure Grafana
169-
170-
```sh
171-
# Get your 'admin' user password
172-
kubectl get secret --namespace cortex grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
173-
```
170+
#### Explore
174171

175172
```sh
176173
# Port-forward to Grafana to visualize
177-
kubectl --namespace cortex port-forward deploy/cortex 3000
174+
kubectl --namespace cortex port-forward deploy/grafana 3000
178175
```
179176

180-
1. Log into the Grafana instance at [http://localhost:3000](http://localhost:3000)
181-
1. Use the username `admin` and the password from the Kubernetes secret
182-
1. Navigate to the [Data Sources](http://localhost:3000/connections/datasources) page
183-
1. Add a new Prometheus Data Source
184-
1. Use `http://cortex-nginx/api/prom` as the URL
185-
1. Click `Save & Test`
186-
1. Go to [Explore](http://localhost:3000/explore) to query metrics
187-
1. Click `Metrics` for a dropdown list of all the available metrics
177+
Grafana is configured to use Cortex as a data source. You can explore the data source in Grafana and query metrics. For example, this [explore](http://localhost:3000/explore?schemaVersion=1&panes=%7B%22au0%22:%7B%22datasource%22:%22P6693426190CB2316%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22rate%28prometheus_remote_storage_samples_total%5B$__rate_interval%5D%29%22,%22range%22:true,%22instant%22:true,%22datasource%22:%7B%22type%22:%22prometheus%22,%22uid%22:%22P6693426190CB2316%22%7D,%22editorMode%22:%22builder%22,%22legendFormat%22:%22__auto%22,%22useBackend%22:false,%22disableTextWrap%22:false,%22fullMetaSearch%22:false,%22includeNullMetadata%22:false%7D%5D,%22range%22:%7B%22from%22:%22now-1h%22,%22to%22:%22now%22%7D%7D%7D&orgId=1) page is showing the rate of samples being sent to Cortex.
178+
188179

189180
If everything is working correctly, then the metrics seen in Grafana were successfully sent from Prometheus to Cortex
190181
via remote_write!
191182

183+
Other things to explore:
184+
185+
```sh
186+
# Port forward to the ingester to see the administrative interface for Cortex:
187+
$ kubectl --namespace cortex port-forward deploy/cortex-ingester 8080
188+
```
189+
190+
- [Cortex Ingester](http://localhost:8080)
191+
- Try shutting down the [ingester](http://localhost:8080/ingester/shutdown) and see how it affects metric ingestion.
192+
- Restart ingester pod to bring the ingester back online, and see if Prometheus affected.
193+
- Does it affect the querying of metrics in Grafana? How many ingesters must be offline before it affects querying?
194+
195+
196+
```sh
197+
# Port forward to Prometheus to see the metrics that are being scraped:
198+
$ kubectl --namespace cortex port-forward deploy/prometheus-server 9090
199+
```
200+
201+
- [Prometheus](http://localhost:9090) - Prometheus instance that is sending metrics to Cortex
202+
- Try querying the metrics in Prometheus.
203+
- Are they the same as what you see in Cortex?
204+
205+
```sh
206+
# Port forward to Prometheus to see the metrics that are being scraped:
207+
$ kubectl --namespace cortex port-forward deploy/grafana 3000
208+
```
209+
210+
- [Grafana](http://localhost:3000) - Grafana instance that is visualizing the metrics.
211+
- Try creating a new dashboard and adding a new panel with a query to Cortex.
212+
192213
### Clean up
193214

194215
```sh

docs/getting-started/cortex-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
target: all,compactor
77

8-
# Disable the requirement that every request to Cortex has a
8+
# Disable the requirement that every request to Cortex has an
99
# X-Scope-OrgID header. `fake` will be substituted in instead.
1010
auth_enabled: false
1111

@@ -49,10 +49,10 @@ ingester:
4949
blocks_storage:
5050
s3: &s3
5151
endpoint: seaweedfs:8333
52-
region: baz
52+
region: local
5353
bucket_name: cortex-bucket
54-
access_key_id: foo
55-
secret_access_key: bar
54+
access_key_id: any
55+
secret_access_key: any
5656
insecure: true
5757
tsdb:
5858
dir: /data/tsdb

docs/getting-started/cortex-values.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ config:
8181
blocks_storage:
8282
s3: &s3
8383
endpoint: seaweedfs.cortex.svc.cluster.local:8333
84-
region: baz
84+
region: local
8585
bucket_name: cortex-bucket
86-
access_key_id: foo
87-
secret_access_key: bar
86+
access_key_id: any
87+
secret_access_key: any
8888
insecure: true
8989
tsdb:
9090
dir: /data/tsdb

docs/getting-started/docker-compose.yaml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
1212

13-
version: "3.8"
14-
1513
services:
1614
cortex:
1715
image: quay.io/cortexproject/cortex:${CORTEX_VERSION}
@@ -20,31 +18,43 @@ services:
2018
volumes:
2119
- ./cortex-config.yaml:/config/cortex-config.yaml:ro
2220
ports:
23-
- 9009:9009
21+
- "9009:9009"
2422
healthcheck:
2523
test: wget -qO- http://localhost:9009/ready
2624
interval: 10s
2725
timeout: 10s
2826
retries: 3
27+
restart: on-failure
2928
grafana:
3029
image: grafana/grafana:${GRAFANA_VERSION}
30+
environment:
31+
- GF_AUTH_ANONYMOUS_ENABLED=true
32+
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
33+
- GF_USERS_DEFAULT_THEME=light
34+
- GF_LOG_MODE=console
35+
- GF_LOG_LEVEL=critical
36+
volumes:
37+
- ./grafana-datasource.yaml:/etc/grafana/provisioning/datasources/datasource.yaml:ro
3138
ports:
32-
- 3000:3000
39+
- "3000:3000"
3340
prometheus:
3441
image: prom/prometheus:${PROMETHEUS_VERSION}
3542
command:
3643
- --config.file=/config/prometheus-config.yaml
3744
volumes:
3845
- ./prometheus-config.yaml:/config/prometheus-config.yaml:ro
3946
ports:
40-
- 9090:9090
47+
- "9090:9090"
4148
seaweedfs:
4249
image: chrislusf/seaweedfs:${SEAWEEDFS_VERSION}
4350
command:
4451
- server
4552
- -s3
53+
- -s3.config=/workspace/seaweedfs-config.json
4654
ports:
47-
- 8333:8333
55+
- "8333:8333"
56+
volumes:
57+
- ./seaweedfs-config.json:/workspace/seaweedfs-config.json:ro
4858
healthcheck:
4959
test: wget -qO- http://localhost:8333/status
5060
interval: 10s
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: 1
2+
3+
datasources:
4+
- name: Cortex
5+
type: prometheus
6+
access: proxy
7+
orgId: 1
8+
url: http://cortex:9009/api/prom
9+
version: 1
10+
editable: true
11+
isDefault: true

docs/getting-started/grafana-values.yaml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,12 @@ admin:
465465
## 6. uncomment the annotation section in the serviceAccount: above
466466
## make sure to replace arn:aws:iam::123456789000:role/iam-role-name-here with your role arn
467467

468-
env: {}
468+
env:
469+
GF_AUTH_ANONYMOUS_ENABLED: true
470+
GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
471+
GF_USERS_DEFAULT_THEME: light
472+
GF_LOG_MODE: console
473+
GF_LOG_LEVEL: critical
469474

470475
## "valueFrom" environment variable references that will be added to deployment pods. Name is templated.
471476
## ref: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#envvarsource-v1-core
@@ -590,15 +595,16 @@ plugins: []
590595
## Configure grafana datasources
591596
## ref: http://docs.grafana.org/administration/provisioning/#datasources
592597
##
593-
datasources: {}
594-
# datasources.yaml:
595-
# apiVersion: 1
596-
# datasources:
597-
# - name: Prometheus
598-
# type: prometheus
599-
# url: http://prometheus-prometheus-server
600-
# access: proxy
601-
# isDefault: true
598+
datasources:
599+
datasources.yaml:
600+
apiVersion: 1
601+
datasources:
602+
- name: Cortex
603+
type: prometheus
604+
url: http://cortex-nginx/api/prom
605+
access: proxy
606+
isDefault: true
607+
editable: true
602608
# - name: CloudWatch
603609
# type: cloudwatch
604610
# access: proxy

docs/getting-started/prometheus-values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ server:
238238
global:
239239
## How frequently to scrape targets by default
240240
##
241-
scrape_interval: 1m
241+
scrape_interval: 15s
242242
## How long until a scrape request times out
243243
##
244244
scrape_timeout: 10s
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"identities": [
3+
{
4+
"name": "cortex",
5+
"credentials": [
6+
{
7+
"accessKey": "any",
8+
"secretKey": "any"
9+
}
10+
],
11+
"actions": [
12+
"Admin"
13+
]
14+
}
15+
]
16+
}

docs/getting-started/seaweedfs.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
creationTimestamp: null
5+
name: seaweedfs-config
6+
data:
7+
seaweedfs-config.json: |-
8+
{
9+
"identities": [
10+
{
11+
"name": "cortex",
12+
"credentials": [
13+
{
14+
"accessKey": "any",
15+
"secretKey": "any"
16+
}
17+
],
18+
"actions": [
19+
"Admin"
20+
]
21+
}
22+
]
23+
}
24+
---
125
apiVersion: apps/v1
226
kind: Deployment
327
metadata:
@@ -22,8 +46,16 @@ spec:
2246
args:
2347
- "server"
2448
- "-s3"
49+
- "-s3.config=/workspace/seaweedfs-config.json"
2550
ports:
2651
- containerPort: 8333
52+
volumeMounts:
53+
- name: seaweedfs-config
54+
mountPath: /workspace
55+
volumes:
56+
- name: seaweedfs-config
57+
configMap:
58+
name: seaweedfs-config
2759
restartPolicy: Always
2860
---
2961
apiVersion: v1

0 commit comments

Comments
 (0)