Skip to content

Commit

Permalink
https://github.com/veertuinc/anka-prometheus-exporter/issues/39
Browse files Browse the repository at this point in the history
  • Loading branch information
NorseGaud committed May 29, 2024
1 parent e340499 commit e554c7c
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 62 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ bin/*
.DS_Store
dist/
anka-prometheus-exporter_linux*
anka-prometheus-exporter_darwin*
anka-prometheus-exporter_darwin*
docker-compose.yml
36 changes: 22 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ services:
ports:
- "2112:2112"
environment:
# DO NOT USE QUOTES AROUND VARIABLES
- ANKA_PROMETHEUS_EXPORTER_CONTROLLER_ADDRESS=http://anka.controller:8090 # change this to your url and port
```
2. `docker-compose pull && docker-compose up --remove-orphans -d`
Expand All @@ -100,8 +101,7 @@ scrape_configs:
## Using TLS
The `--tls` flag is not required if your controller certificate is valid and no client authentication is configured.
For all other TLS configuration options, `--tls` must be set.
The `--tls` flag is not required if your controller certificate is signed with a major CA and no client authentication is configured. For all other TLS configuration options, like self signed scenarios, `--tls` must be enabled.
For self signed certificates, you can either use `--skip-tls-verification` or provide your ca-cert with `--ca-cert`.
Expand All @@ -126,19 +126,19 @@ anka_instance_state_count | Count of Instances in a particular State (label: sta
anka_instance_state_per_template_count | Count of Instances in a particular state, per Template (label: state, template_uuid, template_name)
anka_instance_state_per_group_count | Count of Instances in a particular state, per Group (label: state, group_name)
-- | --
anka_node_instance_count | Count of Instances running on the Node
anka_node_instance_capacity | Total Instance slots (capacity) on the Node
anka_node_instance_count | Count of Instances running on the Node (label: id, name, arch)
anka_node_instance_capacity | Total Instance slots (capacity) on the Node (label: id, name, arch)
anka_node_states | Node state (1 = current state) (label: id, name, state)
anka_node_states_count | Count of Nodes in a particular state (label: state)
anka_node_disk_free_space | Amount of free disk space on the Node in Bytes
anka_node_disk_total_space | Amount of total available disk space on the Node in Bytes
anka_node_disk_anka_used_space | Amount of disk space used by Anka on the Node in Bytes
anka_node_cpu_core_count | Number of CPU Cores in Node
anka_node_cpu_util | CPU utilization in node
anka_node_ram_gb | Total RAM available for the Node in GB
anka_node_ram_util | Total RAM utilized for the Node
anka_node_used_virtual_cpu_count | Total Used Virtual CPU cores for the Node
anka_node_used_virtual_ram_mb | Total Used Virtual RAM for the Node in MB
anka_node_disk_free_space | Amount of free disk space on the Node in Bytes (label: id, name, arch)
anka_node_disk_total_space | Amount of total available disk space on the Node in Bytes (label: id, name, arch)
anka_node_disk_anka_used_space | Amount of disk space used by Anka on the Node in Bytes (label: id, name, arch)
anka_node_cpu_core_count | Number of CPU Cores in Node (label: id, name, arch)
anka_node_cpu_util | CPU utilization in node (label: id, name, arch)
anka_node_ram_gb | Total RAM available for the Node in GB (label: id, name, arch)
anka_node_ram_util | Total RAM utilized for the Node (label: id, name, arch)
anka_node_used_virtual_cpu_count | Total Used Virtual CPU cores for the Node (label: id, name, arch)
anka_node_used_virtual_ram_mb | Total Used Virtual RAM for the Node in MB (label: id, name, arch)
-- | --
anka_node_group_nodes_count | Count of Nodes in a particular Group
anka_node_group_states_count | Count of Groups in a particular State (labels: group, state)
Expand All @@ -156,7 +156,7 @@ anka_node_group_instance_capacity | Total Instance slots (capacity) for the Grou
-- | --
anka_nodes_count | Count of total Anka Nodes
anka_nodes_instance_count | Count of Instance slots in use across all Nodes
anka_nodes_instance_capacity | Count of total Instance Capacity across all Nodes
anka_nodes_instance_capacity | Count of total Instance Capacity across all Nodes, per Architecture (labels: arch)
anka_nodes_disk_free_space | Amount of free disk space across all Nodes in Bytes
anka_nodes_disk_total_space | Amount of total available disk space across all Nodes in Bytes
anka_nodes_disk_anka_used_space | Amount of disk space used by Anka across all Nodes in Bytes
Expand All @@ -178,6 +178,14 @@ anka_registry_template_tags_count | Count of Tags in the Registry for the Templa
---
# Upgrading Considerations
| current version | target version | notes |
| --------------- | -------------- | ----- |
| v2.x | v3.x | The `anka_nodes_instance_capacity` is now split by architecture (label: `arch`). Almost all `anka_node_*` metrics now also include `arch` as a label. |
---
# Development
```bash
Expand Down
44 changes: 22 additions & 22 deletions src/metrics/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,154 +33,154 @@ func (nm NodeMetric) GetEventHandler() func(interface{}) error {
var ankaNodeMetrics = []NodeMetric{
{
BaseAnkaMetric: BaseAnkaMetric{
metric: CreateGaugeMetricVec("anka_node_instance_count", "Count of Instances running on the Node", []string{"id", "name"}),
metric: CreateGaugeMetricVec("anka_node_instance_count", "Count of Instances running on the Node", []string{"id", "name", "arch"}),
event: events.EVENT_NODE_UPDATED,
},
HandleData: func(nodes []types.Node, metric *prometheus.GaugeVec) {
checkAndHandleResetOfGaugeVecMetric(len(nodes), "anka_node_instance_count", metric)
for _, node := range nodes {
if node.NodeName != "" {
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName}).Set(float64(node.VMCount))
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName, "arch": node.Architecture}).Set(float64(node.VMCount))
}
}
},
},
{
BaseAnkaMetric: BaseAnkaMetric{
metric: CreateGaugeMetricVec("anka_node_instance_capacity", "Total Instance slots (capacity) on the Node", []string{"id", "name"}),
metric: CreateGaugeMetricVec("anka_node_instance_capacity", "Total Instance slots (capacity) on the Node", []string{"id", "name", "arch"}),
event: events.EVENT_NODE_UPDATED,
},
HandleData: func(nodes []types.Node, metric *prometheus.GaugeVec) {
checkAndHandleResetOfGaugeVecMetric(len(nodes), "anka_node_instance_capacity", metric)
for _, node := range nodes {
if node.NodeName != "" {
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName}).Set(float64(node.Capacity))
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName, "arch": node.Architecture}).Set(float64(node.Capacity))
}
}
},
},
{
BaseAnkaMetric: BaseAnkaMetric{
metric: CreateGaugeMetricVec("anka_node_disk_free_space", "Amount of free disk space on the Node in Bytes", []string{"id", "name"}),
metric: CreateGaugeMetricVec("anka_node_disk_free_space", "Amount of free disk space on the Node in Bytes", []string{"id", "name", "arch"}),
event: events.EVENT_NODE_UPDATED,
},
HandleData: func(nodes []types.Node, metric *prometheus.GaugeVec) {
checkAndHandleResetOfGaugeVecMetric(len(nodes), "anka_node_disk_free_space", metric)
for _, node := range nodes {
if node.NodeName != "" {
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName}).Set(float64(node.FreeDiskSpace))
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName, "arch": node.Architecture}).Set(float64(node.FreeDiskSpace))
}
}
},
},
{
BaseAnkaMetric: BaseAnkaMetric{
metric: CreateGaugeMetricVec("anka_node_disk_total_space", "Amount of total available disk space on the Node in Bytes", []string{"id", "name"}),
metric: CreateGaugeMetricVec("anka_node_disk_total_space", "Amount of total available disk space on the Node in Bytes", []string{"id", "name", "arch"}),
event: events.EVENT_NODE_UPDATED,
},
HandleData: func(nodes []types.Node, metric *prometheus.GaugeVec) {
checkAndHandleResetOfGaugeVecMetric(len(nodes), "anka_node_disk_total_space", metric)
for _, node := range nodes {
if node.NodeName != "" {
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName}).Set(float64(node.DiskSize))
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName, "arch": node.Architecture}).Set(float64(node.DiskSize))
}
}
},
},
{
BaseAnkaMetric: BaseAnkaMetric{
metric: CreateGaugeMetricVec("anka_node_disk_anka_used_space", "Amount of disk space used by Anka on the Node in Bytes", []string{"id", "name"}),
metric: CreateGaugeMetricVec("anka_node_disk_anka_used_space", "Amount of disk space used by Anka on the Node in Bytes", []string{"id", "name", "arch"}),
event: events.EVENT_NODE_UPDATED,
},
HandleData: func(nodes []types.Node, metric *prometheus.GaugeVec) {
checkAndHandleResetOfGaugeVecMetric(len(nodes), "anka_node_disk_anka_used_space", metric)
for _, node := range nodes {
if node.NodeName != "" {
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName}).Set(float64(node.AnkaDiskUsage))
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName, "arch": node.Architecture}).Set(float64(node.AnkaDiskUsage))
}
}
},
},
{
BaseAnkaMetric: BaseAnkaMetric{
metric: CreateGaugeMetricVec("anka_node_cpu_core_count", "Number of CPU Cores in Node", []string{"id", "name"}),
metric: CreateGaugeMetricVec("anka_node_cpu_core_count", "Number of CPU Cores in Node", []string{"id", "name", "arch"}),
event: events.EVENT_NODE_UPDATED,
},
HandleData: func(nodes []types.Node, metric *prometheus.GaugeVec) {
checkAndHandleResetOfGaugeVecMetric(len(nodes), "anka_node_cpu_core_count", metric)
for _, node := range nodes {
if node.NodeName != "" {
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName}).Set(float64(node.CPU))
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName, "arch": node.Architecture}).Set(float64(node.CPU))
}
}
},
},
{
BaseAnkaMetric: BaseAnkaMetric{
metric: CreateGaugeMetricVec("anka_node_cpu_util", "CPU utilization in node", []string{"id", "name"}),
metric: CreateGaugeMetricVec("anka_node_cpu_util", "CPU utilization in node", []string{"id", "name", "arch"}),
event: events.EVENT_NODE_UPDATED,
},
HandleData: func(nodes []types.Node, metric *prometheus.GaugeVec) {
checkAndHandleResetOfGaugeVecMetric(len(nodes), "anka_node_cpu_util", metric)
for _, node := range nodes {
if node.NodeName != "" {
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName}).Set(float64(node.CPUUtilization))
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName, "arch": node.Architecture}).Set(float64(node.CPUUtilization))
}
}
},
},
{
BaseAnkaMetric: BaseAnkaMetric{
metric: CreateGaugeMetricVec("anka_node_ram_gb", "Total RAM available for the Node in GB", []string{"id", "name"}),
metric: CreateGaugeMetricVec("anka_node_ram_gb", "Total RAM available for the Node in GB", []string{"id", "name", "arch"}),
event: events.EVENT_NODE_UPDATED,
},
HandleData: func(nodes []types.Node, metric *prometheus.GaugeVec) {
checkAndHandleResetOfGaugeVecMetric(len(nodes), "anka_node_ram_gb", metric)
for _, node := range nodes {
if node.NodeName != "" {
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName}).Set(float64(node.RAM))
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName, "arch": node.Architecture}).Set(float64(node.RAM))
}
}
},
},
{
BaseAnkaMetric: BaseAnkaMetric{
metric: CreateGaugeMetricVec("anka_node_ram_util", "Total RAM utilized for the Node", []string{"id", "name"}),
metric: CreateGaugeMetricVec("anka_node_ram_util", "Total RAM utilized for the Node", []string{"id", "name", "arch"}),
event: events.EVENT_NODE_UPDATED,
},
HandleData: func(nodes []types.Node, metric *prometheus.GaugeVec) {
checkAndHandleResetOfGaugeVecMetric(len(nodes), "anka_node_ram_util", metric)
for _, node := range nodes {
if node.NodeName != "" {
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName}).Set(float64(node.RAMUtilization))
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName, "arch": node.Architecture}).Set(float64(node.RAMUtilization))
}
}
},
},
{
BaseAnkaMetric: BaseAnkaMetric{
metric: CreateGaugeMetricVec("anka_node_used_virtual_cpu_count", "Total Used Virtual CPU cores for the Node", []string{"id", "name"}),
metric: CreateGaugeMetricVec("anka_node_used_virtual_cpu_count", "Total Used Virtual CPU cores for the Node", []string{"id", "name", "arch"}),
event: events.EVENT_NODE_UPDATED,
},
HandleData: func(nodes []types.Node, metric *prometheus.GaugeVec) {
checkAndHandleResetOfGaugeVecMetric(len(nodes), "anka_node_used_virtual_cpu_count", metric)
for _, node := range nodes {
if node.NodeName != "" {
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName}).Set(float64(node.UsedVCPUCount))
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName, "arch": node.Architecture}).Set(float64(node.UsedVCPUCount))
}
}
},
},
{
BaseAnkaMetric: BaseAnkaMetric{
metric: CreateGaugeMetricVec("anka_node_used_virtual_ram_mb", "Total Used Virtual RAM for the Node in MB", []string{"id", "name"}),
metric: CreateGaugeMetricVec("anka_node_used_virtual_ram_mb", "Total Used Virtual RAM for the Node in MB", []string{"id", "name", "arch"}),
event: events.EVENT_NODE_UPDATED,
},
HandleData: func(nodes []types.Node, metric *prometheus.GaugeVec) {
checkAndHandleResetOfGaugeVecMetric(len(nodes), "anka_node_used_virtual_ram_mb", metric)
for _, node := range nodes {
if node.NodeName != "" {
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName}).Set(float64(node.UsedVRAM))
metric.With(prometheus.Labels{"id": node.NodeID, "name": node.NodeName, "arch": node.Architecture}).Set(float64(node.UsedVRAM))
}
}
},
Expand Down
Loading

0 comments on commit e554c7c

Please sign in to comment.