Linkerd 2.10 series
- Linkerd v2.10 Service Mesh
- Tencent Cloud K8S deployment Service Mesh — Linkerd2 & Traefik2 deployment emojivoto application
- Learn about the basic features of Linkerd 2.10 and step into the era of Service Mesh
- Linkerd 2.10 – Add your service to Linkerd
- Linkerd 2.10 — Automated Canary release
- Linkerd 2.10 — Automatic rotation controls plane TLS and Webhook TLS credentials
- Linkerd 2.10 — How do I configure external Prometheus instances
- Linkerd 2.10 – Configure proxy concurrency
- Linkerd 2.10 – Configure retry
- Linkerd 2.10 — Configure timeout
- Linkerd 2.10 – Controls the plane debug endpoint
- Linkerd 2.10 – Use Kustomize to customize Linkerd configuration
Linkerd 2.10 中文 版
- linkerd.hacker-linner.com
By design, Linkerd retains metrics data only for a short fixed window of time (currently six hours). This means that if Linkerd’s metric data is valuable to you, you may want to export it to a full-blown metric store.
Internally, Linkerd stores its metrics in Prometheus instances that run as part of the Viz extension. The following tutorial requires the installation of visual extensions with Prometheus enabled. There are several basic ways to export metric data from Linkerd:
- Syndicate the data to your own
Prometheus
The cluster - use
Prometheus
integration - through
Prometheus
的API
Extract the data - Collect data directly from the agent
Use the Prometheus Federation API
If you use Prometheus as your own metric store, we recommend making use of the Federation API for Prometheus, which is designed for use cases where data is copied from one Prometheus to another.
Simply add the following items to scrape_configs in the Prometheus configuration file (replacing {{.namespace}} with a Namespace running the Linkerd Viz extension) :
- job_name: 'linkerd'
kubernetes_sd_configs:
- role: pod
namespaces:
names: ['{{.Namespace}}']
relabel_configs:
- source_labels:
- __meta_kubernetes_pod_container_name
action: keep
regex: ^prometheus$
honor_labels: true
metrics_path: '/federate'
params:
'match[]':
- '{job="linkerd-proxy"}'
- '{job="linkerd-controller"}'
Copy the code
Or, if you prefer to use Prometheus’s ServiceMonitors to configure your Prometheus, You can use this ServiceMonitor YAML (replacing {{.namespace}} with the Namespace running the Linkerd Viz extension) :
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
k8s-app: linkerd-prometheus
release: monitoring
name: linkerd-federate
namespace: {{.Namespace}}
spec:
endpoints:
- interval: 30s
scrapeTimeout: 30s
params:
match[]:
- '{job="linkerd-proxy"}'
- '{job="linkerd-controller"}'
path: /federate
port: admin-http
honorLabels: true
relabelings:
- action: keep
regex: '^prometheus$'
sourceLabels:
- '__meta_kubernetes_pod_container_name'
jobLabel: app
namespaceSelector:
matchNames:
- {{.Namespace}}
selector:
matchLabels:
component: prometheus
Copy the code
That’s it! Your Prometheus cluster is now configured to associate Linkerd’s metrics from an internal Prometheus instance of Linkerd.
Once the indicator is in your Prometheus, Linkerd’s proxy indicator will be labeled job=” Linkerd-Proxy “and Linkerd’s control plane indicator will be labeled Job =” Linkerd-Controller”. For more information about specific metrics and label definitions, see proxy metrics.
For more information about Prometheus’s/Federate endpoints, see the Prometheus Federation documentation.
Integrate with Prometheus
If you do not use Prometheus as your own long-term data store, you can automatically extract data from Linkerd’s Prometheus instance into a data store of your choice using one of Prometheus’s many integrations. See the Prometheus documentation for more information.
Extract data from Prometheus’ API
If neither Prometheus Federation nor Prometheus integration is suitable for you, you can call Prometheus’s API to extract data from Linkerd.
For example, you can invoke the federated API directly with the following command:
curl -G \
--data-urlencode 'match[]={job="linkerd-proxy"}' \
--data-urlencode 'match[]={job="linkerd-controller"}' \
http://prometheus.linkerd-viz.svc.cluster.local:9090/federate
Copy the code
If your data is stored outside the Kubernetes cluster, you may want to set up ingress and authenticate on the domain name of your choice.
Similar to the/Federate API, Prometheus provides a JSON query API to retrieve all metrics:
curl http://prometheus.linkerd-viz.svc.cluster.local:9090/api/v1/query? query=request_totalCopy the code
Collect data directly from the Linkerd agent
Finally, if you want to avoid Linkerd’s Prometheus entirely, you can query the Linkerd agent directly on its /metrics endpoint.
For example, to view /metrics from a single Linkerd agent running in the Linkerd namespace:
kubectl -n linkerd port-forward \
$(kubectl -n linkerd get pods \
-l linkerd.io/control-plane-ns=linkerd \
-o jsonpath='{.items[0].metadata.name}'), 4191-4191Copy the code
And then:
curl localhost:4191/metrics
Copy the code
Alternatively, Linkerd Diagnostics proxy-metrics can be used to retrieve proxy metrics for a given workload.
I am weishao wechat: uuhells123 public number: hackers afternoon tea add my wechat (mutual learning exchange), pay attention to the public number (for more learning materials ~)Copy the code