Na vĂ©spera do inĂcio do curso profissional "Monitoramento e Registro: Zabbix, Prometheus, ELK" , preparamos uma tradução interessante para vocĂȘ, e tambĂ©m oferecemos uma aula de demonstração sobre o tema : "O Prometheus como uma nova rodada de sistemas de monitoramento" .
Introdução
ParabĂ©ns! VocĂȘ conseguiu convencer seus chefes a migrar aplicativos para uma arquitetura de microsserviço usando contĂȘineres e Kubernetes .
VocĂȘ estĂĄ muito feliz e tudo estĂĄ indo de acordo com o planejado. VocĂȘ cria seu primeiro cluster Kubernetes (todos os principais provedores de nuvem - Azure, AWS e GCP - tĂȘm soluçÔes simples para provisionar Kubernetes gerenciados ou nĂŁo gerenciados ), desenvolve seu primeiro aplicativo em contĂȘiner e o implanta no cluster. Foi fĂĄcil, nĂŁo foi?
Depois de um tempo, vocĂȘ percebe que as coisas ficam um pouco mais complicadas: vocĂȘ precisa implantar vĂĄrios aplicativos em um cluster, entĂŁo vocĂȘ precisa de um Ingress Controller . Em seguida, vocĂȘ deseja monitorar a carga, entĂŁo começa a procurar soluçÔes para isso e, felizmente, encontra o Prometheus . Expanda, adicione Grafana e pronto !
: " Prometheus "? ? ? Prometheus ? ? HA DR? Prometheus?
, , .
Kubernetes
Kubernetes.

:
: master- worker-.
Kubernetes.
.
HTTP(s) (REST gRPC), API (Ingress). API :
Kubernetes API Server.
Ingress Controller.
, Azure SQL, Azure Blob .
?
Kubernetes , .
. , , :
.
(, , , ).
(, ..).
, .
Kubernetes. Kubernetes :
â ready ( ), status, restarts ( ), age ( ).
(Deployments) â desired ( ), current ( ), up-to-date ( ), available ( ), age ( ).
StatefulSets.
CronJobs.
( ).
(Health checks).
Kubernetes.
API-.
Etcd.
.
. , . , :
HTTP- ( , , . .).
(, ).
.
, , , .
Thanos
Thanos â , , Prometheus.
Thanos Prometheus . , global view Prometheus.
Thanos:
Sidecar. Prometheus Query Gateway / .
Query Gateway. Prometheus API ( Sidecar Store Gateway).
Store Gateway. .
Compactor. (downsampling) .
Receiver. remote-write WAL Prometheus, / .
Ruler. recording rules alerting rules Thanos.
.
Thanos
Thanos Sidecar Kubernetes, , Prometheus Grafana.
Prometheus, Prometheus-Operator, Kubernetes, Prometheus.
Prometheus-Operator â Helm , , Thanos Sidecar , Kubernetes .
Thanos Sidecar Kubernetes Secret , .
Microsoft Azure.
account blob-:
az storage account create --name <storage_name> --resource-group <resource_group> --location <location> --sku Standard_LRS --encryption blob
( container) :
az storage container create --account-name <storage_name> --name thanos
:
az storage account keys list -g <resource_group> -n <storage_name>
(thanos-storage-config.yaml):
Kubernetes Secret:
kubectl -n monitoring create secret generic thanos-objstore-config --from-file=thanos.yaml=thanos-storage-config.yaml
prometheus-operator-values.yaml, Prometheus-Operator.
:
helm install --namespace monitoring --name prometheus-operator stable/prometheus-operator -f prometheus-operator-values.yaml
Prometheus Thanos Sidecar, Azure Blob Storage .
Thanos Store Gateway Thanos Sidecar, Ingress. Nginx Ingress Controller, Ingress Controller, gRPC (, Envoy ).
Thanos Store Gateway Thanos Sidecar mutual TLS. .
.pfx-, , openssl:
# public key
openssl pkcs12 -in cert.pfx -nocerts -nodes | sed -ne '/-BEGIN PRIVATE KEY-/,/-END PRIVATE KEY-/p' > cert.key
# private key
openssl pkcs12 -in cert.pfx -clcerts -nokeys | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > cert.cer
# certificate authority (CA)
openssl pkcs12 -in cert.pfx -cacerts -nokeys -chain | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > cacerts.cer
Kubernetes Secrets.
# a secret to be used for TLS termination
kubectl create secret tls -n monitoring thanos-ingress-secret --key ./cert.key --cert ./cert.cer
# a secret to be used for client authenticating using the same CA
kubectl create secret generic -n monitoring thanos-ca-secret --from-file=ca.crt=./cacerts.cer
, , Kubernetes, , Thaos SideCar:
thanos-0.your.domain
thanos-1.your.domain
Ingress ( ):
Thanos Sidecars !
Thanos
Thanos, , , Thanos . , , .
thanos-values.yaml, .
Thanos Store Gateway blob-, .
kubectl -n thanos create secret generic thanos-objstore-config --from-file=thanos.yaml=thanos-storage-config.yaml
, .
helm install --name thanos --namespace thanos ./thanos -f thanos-values.yaml --set-file query.tlsClient.cert=cert.cer --set-file query.tlsClient.key=cert.key --set-file query.tlsClient.ca=cacerts.cer --set-file store.tlsServer.cert=cert.cer --set-file store.tlsServer.key=cert.key --set-file store.tlsServer.ca=cacerts.cer
Thanos Query Gateway Thanos Storage Gateway, .
, , HTTP- Thanos Query Gateway :
kubectl -n thanos port-forward svc/thanos-query-http 8080:10902
http://localhost:8080, Thanos UI!

Grafana
Grafana, Helm .
grafana-values.yaml :
, . ( â ConfigMap).
:
helm install --name grafana --namespace thanos stable/grafana -f grafana-values.yaml
port-forward:
kubectl -n thanos port-forward svc/grafana 8080:80
⊠! Prometheus !
Prometheus Thanos, global view , Prometheus .
Cortex â , , Thanos, .
? -, - OTUS .