|
| 1 | +## This configuration collects Vault metrics and status information from various Vault endpoints. |
| 2 | +## For all available endpoints: https://developer.hashicorp.com/vault/api-docs/system |
| 3 | +## To poll metrics, see: https://github.com/newrelic/nri-vault |
| 4 | + |
| 5 | +integrations: |
| 6 | + - name: nri-flex |
| 7 | + interval: 120s |
| 8 | + config: |
| 9 | + name: hashicorpVaultFlex |
| 10 | + global: |
| 11 | + base_url: http://127.0.0.1:8200/v1/ |
| 12 | + ## Token-based auth - only required for token-based authentication endpoints |
| 13 | + ## (uncomment and set token as env variable if you add more api blocks that require a token) |
| 14 | + # headers: |
| 15 | + # X-Vault-Token: $$VAULT_TOKEN |
| 16 | + |
| 17 | + apis: |
| 18 | + # --------------------------------------------------------- |
| 19 | + # API 1: Health Check & Service Checks |
| 20 | + # https://developer.hashicorp.com/vault/api-docs/system/health |
| 21 | + # --------------------------------------------------------- |
| 22 | + - event_type: VaultHealthSample |
| 23 | + url: sys/health |
| 24 | + url_params: |
| 25 | + standbyok: true |
| 26 | + perfstandbyok: true |
| 27 | + jq: >- |
| 28 | + .[0] | { |
| 29 | + version: .version, |
| 30 | + cluster_name: (.cluster_name // "unknown"), |
| 31 | + cluster_id: .cluster_id, |
| 32 | + server_time_utc: .server_time_utc, |
| 33 | + initialized: (if .initialized then 1 else 0 end), |
| 34 | + sealed: (if .sealed then 1 else 0 end), |
| 35 | + standby: (if .standby then 1 else 0 end), |
| 36 | + performance_standby: (if .performance_standby then 1 else 0 end), |
| 37 | + is_leader: (if .standby == false then 1 else 0 end), |
| 38 | + replication_dr_mode: (.replication_dr_mode // "unknown"), |
| 39 | + replication_performance_mode: (.replication_performance_mode // "unknown"), |
| 40 | + service_check_unsealed: (if .sealed == false then "ok" else "critical" end), |
| 41 | + service_check_initialized: (if .initialized then "ok" else "critical" end) |
| 42 | + } |
| 43 | +
|
| 44 | + # --------------------------------------------------------- |
| 45 | + # API 2: Leader Status & HA Info |
| 46 | + # https://developer.hashicorp.com/vault/api-docs/system/leader |
| 47 | + # --------------------------------------------------------- |
| 48 | + - event_type: VaultLeaderSample |
| 49 | + url: sys/leader |
| 50 | + jq: >- |
| 51 | + .[0] | { |
| 52 | + ha_enabled: (if .ha_enabled then 1 else 0 end), |
| 53 | + is_self: (if .is_self then 1 else 0 end), |
| 54 | + active_time: .active_time, |
| 55 | + leader_address: .leader_address, |
| 56 | + leader_cluster_address: .leader_cluster_address, |
| 57 | + performance_standby: (if .performance_standby then 1 else 0 end), |
| 58 | + performance_standby_last_remote_wal: .performance_standby_last_remote_wal, |
| 59 | + last_wal: .last_wal, |
| 60 | + raft_committed_index: .raft_committed_index, |
| 61 | + raft_applied_index: .raft_applied_index |
| 62 | + } |
| 63 | +
|
| 64 | + # --------------------------------------------------------- |
| 65 | + # API 3: Seal Status (detailed seal info) |
| 66 | + # https://developer.hashicorp.com/vault/api-docs/system/seal-status |
| 67 | + # --------------------------------------------------------- |
| 68 | + - event_type: VaultSealSample |
| 69 | + url: sys/seal-status |
| 70 | + jq: >- |
| 71 | + .[0] | { |
| 72 | + sealed: (if .sealed then 1 else 0 end), |
| 73 | + threshold: .t, |
| 74 | + shares: .n, |
| 75 | + progress: .progress, |
| 76 | + nonce: .nonce, |
| 77 | + version: .version, |
| 78 | + build_date: .build_date, |
| 79 | + migration: (if .migration then 1 else 0 end), |
| 80 | + cluster_name: (.cluster_name // "unknown"), |
| 81 | + cluster_id: .cluster_id, |
| 82 | + recovery_seal: (if .recovery_seal then 1 else 0 end), |
| 83 | + storage_type: .storage_type, |
| 84 | + namespace: (.namespace // null) |
| 85 | + } |
| 86 | +
|
| 87 | + # --------------------------------------------------------- |
| 88 | + # API 4: [Enterprise Only] Replication Status |
| 89 | + # https://developer.hashicorp.com/vault/api-docs/system/replication#check-status |
| 90 | + # --------------------------------------------------------- |
| 91 | + - event_type: VaultReplicationSample |
| 92 | + url: sys/replication/status |
| 93 | + jq: >- |
| 94 | + .[0].data | to_entries | map({ |
| 95 | + replication_node_state: .key, |
| 96 | + cluster_id: .value.cluster_id, |
| 97 | + last_wal: .value.last_wal, |
| 98 | + merkle_root: .value.merkle_root, |
| 99 | + mode: .value.mode, |
| 100 | + primary_cluster_addr: .value.primary_cluster_addr, |
| 101 | + known_secondaries: (.value.known_secondaries | join(",")), |
| 102 | + "secondaries.api_address": (.value.secondaries[0].api_address // null), |
| 103 | + "secondaries.cluster_address": (.value.secondaries[0].cluster_address // null), |
| 104 | + "secondaries.connection_status": (.value.secondaries[0].connection_status // null), |
| 105 | + "secondaries.last_heartbeat": (.value.secondaries[0].last_heartbeat // null), |
| 106 | + "secondaries.node_id": (.value.secondaries[0].node_id // null) |
| 107 | + }) |
0 commit comments