• 카테고리

    질문 & 답변
  • 세부 분야

    데브옵스 · 인프라

  • 해결 여부

    미해결

프로메테우스

22.04.17 15:02 작성 조회수 466

0

안녕하세요. 강의 잘 들었습니다.
여쭤보고 싶은 것은
 
1.
PV는 왜 Prometheus yaml 파일에 적어주고
PVC는 왜 Grafana yaml 파일에 각자 따로 적어주나요?
PVC는 PV와 같이 있어야 할 것 같은데 따로 적어주는 이유가 궁금합니다.
 
2.
타겟을 따로 exporter로 지정해주고 싶은데
values-prometheus.yaml 파일이 프로메테우스 설정 파일이라고 봐도 되나요?
아니면 따로 야믈 파일을 생성해서 프로메테우스 타겟을 설정해주어야 하나요?

답변 1

답변을 작성해보세요.

0

gasbugs님의 프로필

gasbugs

2022.04.18

안녕하세요 강사 최일선입니다.
 
 
1.
PV는 왜 Prometheus yaml 파일에 적어주고
PVC는 왜 Grafana yaml 파일에 각자 따로 적어주나요?
PVC는 PV와 같이 있어야 할 것 같은데 따로 적어주는 이유가 궁금합니다.
 
 
A: 둘을 각각으로 보시면 됩니다.
Prometheus yaml에서 적어준 정보는 프로메테우스의 데이터를 위한 정보입니다.
Grafana yaml에서 적어준 정보는 대시보드의 정보 저장을 위한 정보입니다.
따라서 각 PVC와 PV를 구성하게 되므로 서로 연관성은 없습니다.
제 생각에는 이름 표기 때문에 헷갈려 하시는 것 같습니다.
PV로 표기할지 PVC로 표기할지는 헬름 차트 개발자가 정해둔 것이라서 저희가 사용할 때는
그 규칙에 맞게 구성한 것입니다~
 
 
2.
타겟을 따로 exporter로 지정해주고 싶은데
values-prometheus.yaml 파일이 프로메테우스 설정 파일이라고 봐도 되나요?
아니면 따로 야믈 파일을 생성해서 프로메테우스 타겟을 설정해주어야 하나요?
 
앞서 사용하신 프로메테우스는 구성한 헬름 차트는 데이터베이스 및 에이전트까지 구성한 예제입니다.
exporter만 따로 구성하시려면 다음 사이트의 기능을 사용 하시면 됩니다.
https://artifacthub.io/packages/helm/prometheus-community/prometheus-node-exporter
 
노드 익스포터는 endpoints에 대한 value를 별도로 설정 가능합니다.
https://artifacthub.io/packages/helm/prometheus-community/prometheus-node-exporter/1.11.0
 
감사합니다.
lin7258님의 프로필

lin7258

질문자

2022.04.23

강사님.. 너무 어렵습니다 ㅜㅋㅋㅋㅋㅋ

사실 지금 쿠버네티스 클러스터에 올린 것이 아니라 미니큐브 인스턴스에 프로메테우스와 그라파나를 올린 상황입니다. 
그래서 다른 mongodb 인스턴스를 모니터링하고, alert manager로 슬랙 알림을 주고 싶습니다.

깃허브에 있는 prometheus의 values.yaml 파일을 참고하여 강사님께서 작성하신 values-prometheus.yaml 파일을
아래와 같이 수정하였습니다.

cat <<EOF > values-prometheus.yaml

alertmanager: # 30~33
  enabled: true
  persistentVolume:
    ## If true, alertmanager will create/use a Persistent Volume Claim
    ## If false, use emptyDir
    enabled: true
    accessModes:
      - ReadWriteOnce
    size: 2Gi
    replicaCount: 1
  service:
    type: LoadBalancer

## alertmanager ConfigMap entries # 1360
alertmanagerFiles:
  alertmanager.yml:
    global:
       resolve_timeout: 5m
       slack_api_url: 'https://hooks.slack.com/services/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'
    route:
      group_by: ['monitoring']
      group_wait: 30s
      repeat_interval: 1h
      receiver: default-receiver
      routes:
      - match:
          alertname: DeadMansSwitch
        receiver: 'null'
      - match:
        receiver: 'slack'
        continue: true
    receivers:
    - name: 'null'
    - name: 'slack'
      slack_configs:
       - channel: 'test'
         username: 'prometheus'
         send_resolved: true
         icon_url: https://avatars3.githubusercontent.com/u/3380462
         title: |-
          [{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .CommonLabels.alertname }} for {{ .CommonLabels.job }}
         text: >-
            {{ range .Alerts -}}
            *Alert:* {{ .Annotations.title }}{{ if .Labels.severity }} - {{ end }}

            *Description:* {{ .Annotations.description }}

            *Details:*
              {{ range .Labels.SortedPairs }} • *{{ .Name }}:*
              {{ end }}
            {{ end }}

server:
  enabled: true

  persistentVolume:
    enabled: true
    accessModes:
      - ReadWriteOnce
    mountPath: /data
    size: 100Gi
  replicaCount: 1

  ## Prometheus data retention period (default if not specified is 15 days)
  retention: "15d"  # 15일간 데이터를 보존함

serverFiles:
  alerting_rules.yml:
    groups:
    - name: example
      rules:
      - alert: HighRequestLatency
        expr: sum(rate(container_network_receive_bytes_total{namespace="kube-logging"}[5m]))>20000
        for: 1m
        labels:
          severity: page
        annotations:
          summary: High request latency

  prometheus.yml:
    rule_files:
      - /etc/config/alerting_rules.yml
      - /etc/config/alerts

EOF

helm install 하였더니 alertmanager 파드에서 Crash Loop BackOff 오류가 납니다... 이미지가 이미 존재한다는데 어떻게 해야 할지 모르겠습니다.

 

2. 

그리고 몽고디비를 타겟으로 설정하기 위해 깃허브에 있던 mongodb-exporter.yaml 파일을 가져와

cat <<EOF > mongodb.yaml
mongodb:
  uri: "mongodb://mongodb0.example.com:27017"
existingSecret:
  name: "MONGO_INITDB_ROOT_PASSWORD"
  key: "secret"
port: "80"

readinessProbe:
  httpGet:
    path: /
    port: metrics
  initialDelaySeconds: 10

metrics:
  enabled: true

	serviceMonitor:
	  enabled: true
	  interval: 30s
	  scrapeTimeout: 10s
	  namespace:
	  additionalLabels: {}
	  targetLabels: []
	  metricRelabelings: []

EOF

라고 저장 후 
helm install mongodb prometheus-community/prometheus-mongodb-exporter -f mongodb.yaml -n prometheus 해주었는데 이렇게 하는 게 맞을까요?

 

질문이 두서없고 정신이 없네요... 

늘 감사합니다.

 

 

gasbugs님의 프로필

gasbugs

2022.04.25

안녕하세요 강사 최일선입니다.

개인 프로젝트에 관련해서는 테스트 해보고 말씀 드려야해서 시간이 다소 소요됩니다.

테스트하고 추가 답변 드리겠습니다. 감사합니다.