본문 바로가기
Engineering

Grafana Mimir란? && 설치 테스트

by weq155 2024. 3. 8.
반응형
반응형

Grafana Mimir

Grafana Mimir project forked from Cortex. Various different methods you can use to ingest data but for this PoC I chose to use prometheus with remote write.

Pros

Cons

  • As it stands, only helm and jsonnet deployment available
  • Complicated setup with many components
  • Fairly new project — limited resources online for guidance
  • Lack of documentation
  • Not widely adopted by community

install

https://grafana.com/docs/helm-charts/mimir-distributed/latest/get-started-helm-charts/

Before you begin

  • General knowledge about using a Kubernetes cluster.
  • Understanding of what the kubectl command does.
  • Understanding of what the helm command does.

• A single Kubernetes node with a minimum of 4 cores and 16GiB RAM

helm repo add grafana <https://grafana.github.io/helm-charts>
helm repo update

helm -n mimir install mimir grafana/mimir-distributed --create-namespace

kubectl -n mimir get pods

Generate some metrics for testing

The Grafana Mimir Helm chart can collect metrics, logs, or both, about Grafana Mimir itself. This is called metamonitoring. In the example that follows, metamonitoring scrapes metrics about Grafana Mimir itself, and then writes those metrics to the same Grafana Mimir instance.

  1. Download the Grafana Agent Operator Custom Resource Definitions (CRDs) from https://github.com/grafana/agent/tree/main/production/operator/crds.If you did not enable metamonitoring when the chart was first installed, you must manually install the CRDs before performing a Helm upgrade to enable metamonitoring.
  2. Helm only installs Custom Resource Definitions on an initial chart installation, and not on a chart upgrade. For details, see Some caveats and explanations.
  3. Install the CRDs on your cluster:
git clone <https://github.com/grafana/agent.git>

cd agent/
kubectl create -f production/operator/crds/

----
metaMonitoring:
  serviceMonitor:
    enabled: true
  grafanaAgent:
    enabled: true
    installOperator: true
    metrics:
      additionalRemoteWriteConfigs:
        - url: "<http://mimir-nginx.mimir-test.svc:80/api/v1/push>"
---

helm -n mimir upgrade mimir grafana/mimir-distributed -f custom.yaml

install grafana

https://grafana.com/docs/grafana/latest/setup-grafana/installation/kubernetes/

touch grafana.yaml

vim grafana.yaml
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: grafana-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: grafana
  name: grafana
spec:
  selector:
    matchLabels:
      app: grafana
  template:
    metadata:
      labels:
        app: grafana
    spec:
      securityContext:
        fsGroup: 472
        supplementalGroups:
          - 0
      containers:
        - name: grafana
          image: grafana/grafana:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 3000
              name: http-grafana
              protocol: TCP
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /robots.txt
              port: 3000
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 2
          livenessProbe:
            failureThreshold: 3
            initialDelaySeconds: 30
            periodSeconds: 10
            successThreshold: 1
            tcpSocket:
              port: 3000
            timeoutSeconds: 1
          resources:
            requests:
              cpu: 250m
              memory: 750Mi
          volumeMounts:
            - mountPath: /var/lib/grafana
              name: grafana-pv
      volumes:
        - name: grafana-pv
          persistentVolumeClaim:
            claimName: grafana-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: grafana
spec:
  ports:
    - port: 3000
      protocol: TCP
      targetPort: http-grafana
  selector:
    app: grafana
  sessionAffinity: None
  type: LoadBalancer

kubectl apply -f grafana.yaml --namespace=mimir-test

NAME                             TYPE           CLUSTER-IP     EXTERNAL-IP    PORT(S)                      AGE
grafana                          LoadBalancer   10.84.14.175   34.97.70.203   3000:31585/TCP               17m

<http://34.97.70.203:3000>

추가 헬름차트 안전하게 관리 helm diff

https://grafana.com/docs/helm-charts/mimir-distributed/latest/run-production-environment-with-helm/configuration-with-helm/

https://github.com/databus23/helm-diff

helm plugin install <https://github.com/databus23/helm-diff>

helm -n mimir-test diff upgrade mimir grafana/mimir-distributed -f custom.yaml
반응형