ÉèΪÊ×Ò³ - ¼ÓÈëÊÕ²Ø ASPÕ¾³¤Íø£¨Aspzz.Cn£©- ¿Æ¼¼¡¢½¨Õ¾¡¢¾­Ñé¡¢ÔƼÆËã¡¢5G¡¢´óÊý¾Ý,Õ¾³¤Íø£¡
ÈÈËÑ£º ÊÖ»ú Êý¾Ý ¹«Ë¾
µ±Ç°Î»Ö㺠Ê×Ò³ > ·þÎñÆ÷ > ´î½¨»·¾³ > Windows > ÕýÎÄ

Ò»ÎĶÁ¶®ÈçºÎÔÚKubernetesÉÏÇáËÉʵÏÖ×Ô¶¯»¯²¿ÊðPrometheus(5)

·¢²¼Ê±¼ä£º2019-08-28 00:22 ËùÊôÀ¸Ä¿£º117 À´Ô´£º»ðÑÛâ¡â¥
µ¼¶Á£ºÈ»ºóɾ³ý kube-proxy µÄ Pod£¬ÈÃËüÖØÆô¼´¿É¿´µ½ÒÑÕý³£×¥È £ Ó¦Óà ÖÁ´Ë£¬Prometheus µÄ·þÎñ¶Ë¾ÍÈ«²¿²¿ÊðÍê³ÉÁË¡£½ÓÏÂÀ´¾ÍÊǸù¾Ýʵ¼ÊÒµÎñ²¿ÊðÏàÓ¦µÄ Exporter£¬ServiceMonitor ºÍ PrometheusRule ÁË¡£¹Ù·½ºÍÉçÇøÓдó

È»ºóɾ³ý kube-proxy µÄ Pod£¬ÈÃËüÖØÆô¼´¿É¿´µ½ÒÑÕý³£×¥È¡¡£

Ò»ÎĶÁ¶®ÈçºÎÔÚKubernetesÉÏÇáËÉʵÏÖ×Ô¶¯»¯²¿ÊðPrometheus

Ó¦ÓÃ

ÖÁ´Ë£¬Prometheus µÄ·þÎñ¶Ë¾ÍÈ«²¿²¿ÊðÍê³ÉÁË¡£½ÓÏÂÀ´¾ÍÊǸù¾Ýʵ¼ÊÒµÎñ²¿ÊðÏàÓ¦µÄ Exporter£¬ServiceMonitor ºÍ PrometheusRule ÁË¡£¹Ù·½ºÍÉçÇøÓдóÁ¿ÏÖ³ÉµÄ Exporters ¿É¹©Ê¹Óã¬Èç¹ûÓÐÌØÊâÐèÇóµÄÒ²¿ÉÒԲο¼ÕâÀï×ÔÐпª·¢¡£

½ÓÏÂÀ´ÎÒÃǽ²½²ÈçºÎ¿ìËÙ¼¯³É Prometheus ¼à¿ØºÍ±¨¾¯¡£

ÎÒÃÇ֮ǰÌáµ½¹ý Operator ͨ¹ý CRD µÄ·½Ê½ÌṩÁ˺ܶಿÊð·½ÃæµÄ×Ô¶¯»¯£¬Prometheus-Operator ¾ÍÌṩÁËËĸö CRD£¬·Ö±ðÊÇ

  •  Prometheus£¬¶¨ÒåÁË Prometheus ·þÎñ¶Ë£¬ÓÃÀ´Éú³É·þÎñ¶Ë¿ØÖÆÆ÷£¬±£Ö¤ÁË·þÎñ¶ËµÄÕý³£ÔËÐУ¬ÎÒÃÇÖ»ÐèÒªÒ»¸ö´Ë CRD µÄʵÀý
  •  Alertmanager£¬¶¨ÒåÁË AlertManager ·þÎñ£¬ÓÃÀ´Éú³É·þÎñ¶Ë¿ØÖÆÆ÷£¬±£Ö¤ÁË·þÎñµÄÕý³£ÔËÐУ¬ÎÒÃÇÒ²Ö»ÐèÒªÒ»¸ö´Ë CRD µÄʵÀý
  •  ServiceMonitor£¬¶¨ÒåÁË Prometheus ץȡָ±êµÄÄ¿±ê£¬¾ÍÊÇ Prometheus ½çÃæ targets Ò³Ãæ¿´µ½µÄÄÚÈÝ£¬´Ë CRD °ïÖúÎÒÃÇ´´½¨Ä¿±êµÄÅäÖÃ
  •  PrometheusRule£¬¶¨ÒåÁË Prometheus ¹æÔò£¬¾ÍÊÇ Prometheus ½çÃæ Rules Ò³Ãæ¿´µ½µÄÄÚÈÝ£¬´Ë CRD °ïÖúÎÒÃÇ´´½¨¹æÔòµÄÅäÖÃ

Prometheus ºÍ Alertmanager CRD Ö÷ÒªÊÇ֮ǰ²¿Êð½×¶Î¹Ø×¢µÄ£¬ÔÚ·þÎñÓ¦Óý׶Σ¬ÎÒÃÇÖ÷ÒªÊÇ´´½¨¸÷¸ö ServiceMonitor ºÍ PrometheusRule À´ÅäÖ÷þÎñ¶Ë¡£

Prometheus-Operator ĬÈÏ»á°ïÎÒÃÇ×¢²áÏà¹Ø×é¼þµÄץȡĿ±ê£¬ÈçÏÂͼËùʾ

Ò»ÎĶÁ¶®ÈçºÎÔÚKubernetesÉÏÇáËÉʵÏÖ×Ô¶¯»¯²¿ÊðPrometheus

ÎÒÃÇÒª¶¨ÒåÆäËûµÄץȡĿ±ê£¬Ê×ÏÈÀ´´´½¨ÁËÒ»¸ö ServiceMonitor ץȡÎÒÃDz¿ÊðµÄ InfluxDB µÄÖ¸±ê

  1. apiVersion: monitoring.coreos.com/v1  
  2. kind: ServiceMonitor  
  3. metadata:  
  4.   name: influxdb-scrape-targets  
  5.   labels:  
  6.     app.kubernetes.io/name: scrape-targets  
  7.     app.kubernetes.io/instance: influxdb-target  
  8.     release: prometheus  
  9. spec:  
  10.   # ÓñêÇ©Ñ¡ÔñÆ÷À´Ñ¡ÔñÏàÓ¦µÄ Pod  
  11.   selector:  
  12.     matchLabels:  
  13.       app: influxdb  
  14.       release: influxdb  
  15.   # Ñ¡ÔñÃüÃû¿Õ¼ä  
  16.   namespaceSelector:  
  17.     matchNames:  
  18.     - monitoring  
  19.   # ¶¨ÒåץȡµÄÅäÖã¬Èç¶Ë¿Ú¡¢ÆµÂʵȠ 
  20.   endpoints:  
  21.     - interval: 15s  
  22.       port: api 

ÎÒÃÇÔÚÏîÄ¿Öд´½¨ÁËÒ»¸ö Chart Ä£°æ£¨ÔÚ charts/scrape-targets/ Ŀ¼£©£¬Äܹ»¿ìËٵĴ´½¨ ServiceMonitor£¬ÌṩÏÂÃæµÄÅäÖÃÎļþ

influxdb.yaml

  1. selector:  
  2.   matchLabels:  
  3.     app: influxdb  
  4.     release: influxdb  
  5. namespaceSelector:  
  6.   matchNames:  
  7.     - monitoring  
  8. endpoints:  
  9.   - port: api  
  10.     interval: 15s 

£¨±à¼­£ºASPÕ¾³¤Íø£©

ÍøÓÑÆÀÂÛ
ÍƼöÎÄÕÂ
    ÈȵãÔĶÁ