티스토리 뷰

카테고리 없음

Splunk 인덱스별 크기(size)

자바바라 2025. 9. 5. 00:03

Splunk 인덱스별 크기(size) Grafana.Dashboard

  1. Splunk 검색 쿼리 (REST API or SPL) → 인덱스별 크기 가져오기
  2. Grafana 데이터소스: Splunk용 플러그인 사용 (예: grafana-splunk-datasource)
  3. 대시보드 JSON: Splunk 쿼리 결과를 그래프로

1) Splunk에서 인덱스 크기 확인 SPL

Splunk 자체에서 제공하는 쿼리:

| rest /services/data/indexes 
| fields title currentDBSizeMB frozenTimePeriodInSecs totalEventCount
| eval sizeGB = round(currentDBSizeMB/1024,2)
| table title sizeGB totalEventCount
  • title → 인덱스 이름
  • sizeGB → 인덱스 크기(GB)
  • totalEventCount → 이벤트 개수

2) Grafana에서 Splunk 데이터소스 등록

  • Grafana에 Splunk 플러그인 설치 후
  • Splunk REST API URL + 인증 토큰 입력

3) Grafana 대시보드 JSON (Bar Chart로 인덱스 크기)

{
  "id": null,
  "title": "Splunk Index Size",
  "schemaVersion": 38,
  "version": 1,
  "panels": [
    {
      "type": "barchart",
      "title": "Index Size (GB)",
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "grafana-splunk-datasource",
            "uid": "your-splunk-datasource-uid"
          },
          "query": "| rest /services/data/indexes | fields title currentDBSizeMB | eval sizeGB=round(currentDBSizeMB/1024,2) | table title sizeGB"
        }
      ],
      "options": {
        "orientation": "horizontal",
        "stacking": "none",
        "showValue": "always",
        "barWidth": 0.8,
        "legend": {
          "showLegend": false
        }
      },
      "fieldConfig": {
        "defaults": {
          "unit": "gbytes",
          "decimals": 2
        }
      },
      "gridPos": {
        "h": 12,
        "w": 24,
        "x": 0,
        "y": 0
      }
    }
  ],
  "time": {
    "from": "now-24h",
    "to": "now"
  }
}

이걸 Grafana에 Import 하면:

  • X축 → 인덱스 이름(title)
  • Y축 → 크기(GB)
  • Bar Chart로 인덱스별 크기 비교

Splunk 인덱스 크기(Time Series 추세)를 Prometheus + Grafana 시각화

  1. Splunk → Prometheus Exporter로 메트릭 수집
  2. Grafana Dashboard에서 Panel 구성

1. Splunk Index Size 수집 방법

Splunk CLI로 인덱스 크기 확인:

splunk _internal call /services/data/indexes | grep -E '"indexName"| "currentDBSizeMB"'

또는 더 간단히:

splunk list index

이 값을 Prometheus Exporter 스크립트로 변환 (예: Node Exporter Textfile Collector 사용):

splunk_index_exporter.sh

#!/bin/bash
OUTPUT="/var/lib/node_exporter/textfile_collector/splunk_index.prom"

echo "# HELP splunk_index_size_bytes Splunk index size in bytes" > $OUTPUT
echo "# TYPE splunk_index_size_bytes gauge" >> $OUTPUT

splunk list index | awk '{print $1, $2}' | while read index size; do
    # size 단위를 MB → Bytes 변환
    size_bytes=$(echo "$size*1024*1024" | bc)
    echo "splunk_index_size_bytes{index=\"$index\"} $size_bytes" >> $OUTPUT
done

이 스크립트를 cron에 넣어서 5분마다 실행하면 Prometheus가 자동 수집 가능.

 

2. Grafana Dashboard JSON 예시

(a) 현재 인덱스 크기 (Bar Chart)

{
  "type": "barchart",
  "title": "Splunk Index Size (Current)",
  "targets": [
    {
      "expr": "splunk_index_size_bytes",
      "legendFormat": "{{index}}"
    }
  ],
  "options": {
    "orientation": "horizontal",
    "displayMode": "gradient"
  }
}

(b) 시간에 따른 인덱스 크기 변화 (Time Series)

{
  "type": "timeseries",
  "title": "Splunk Index Size Trend (Last 24h)",
  "targets": [
    {
      "expr": "splunk_index_size_bytes",
      "legendFormat": "{{index}}"
    }
  ],
  "fieldConfig": {
    "defaults": {
      "unit": "bytes",
      "min": 0
    }
  }
}

Dashboard는 두 개 패널:

  • Panel 1: Bar Chart → 현재 인덱스별 크기
  • Panel 2: Time Series → 시간에 따른 인덱스별 크기 변화

기존 Grafana 대시보드에 바로 추가

1. Splunk Index Size (현재값 Bar Chart)

{
  "id": null,
  "gridPos": { "h": 8, "w": 12, "x": 0, "y": 0 },
  "type": "barchart",
  "title": "Splunk Index Size (Current)",
  "targets": [
    {
      "expr": "splunk_index_size_bytes",
      "legendFormat": "{{index}}"
    }
  ],
  "options": {
    "orientation": "horizontal",
    "displayMode": "gradient",
    "reduceOptions": {
      "calcs": ["lastNotNull"],
      "fields": "",
      "values": false
    }
  },
  "fieldConfig": {
    "defaults": {
      "unit": "bytes",
      "decimals": 2
    }
  }
}

2. Splunk Index Size Trend (시간 추세 Time Series)

{
  "id": null,
  "gridPos": { "h": 8, "w": 12, "x": 12, "y": 0 },
  "type": "timeseries",
  "title": "Splunk Index Size Trend (Last 24h)",
  "targets": [
    {
      "expr": "splunk_index_size_bytes",
      "legendFormat": "{{index}}"
    }
  ],
  "fieldConfig": {
    "defaults": {
      "unit": "bytes",
      "decimals": 2,
      "min": 0
    }
  },
  "options": {
    "legend": {
      "displayMode": "list",
      "placement": "right"
    }
  }
}

사용 방법:

  1. Grafana에서 대시보드 편집 → JSON 모델 들어가기
  2. "panels": [ ... ] 안에 위 JSON 두 블록을 그대로 붙여넣기
  3. 저장 후 확인
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG more
«   2026/10   »
일 월 화 수 목 금 토
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함