Skip to content

Commit

Permalink
Added label tenant_id to limits_vcpus_max, limits_vcpus_used, limits_…
Browse files Browse the repository at this point in the history
…memory_max, limits_memory_used (#92)

Without this label there will be errors when there are projects having the same project name, for project name is not uniq in OpenStack
  • Loading branch information
tzmtl committed Mar 26, 2020
1 parent 767d43f commit c99b822
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions exporters/nova.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ var defaultNovaMetrics = []Metric{
{Name: "local_storage_used_bytes", Labels: []string{"hostname", "availability_zone", "aggregates"}},
{Name: "server_status", Labels: []string{"id", "status", "name", "tenant_id", "user_id", "address_ipv4",
"address_ipv6", "host_id", "uuid", "availability_zone", "flavor_id"}},
{Name: "limits_vcpus_max", Labels: []string{"tenant"}, Fn: ListComputeLimits},
{Name: "limits_vcpus_used", Labels: []string{"tenant"}},
{Name: "limits_memory_max", Labels: []string{"tenant"}},
{Name: "limits_memory_used", Labels: []string{"tenant"}},
{Name: "limits_vcpus_max", Labels: []string{"tenant", "tenant_id"}, Fn: ListComputeLimits},
{Name: "limits_vcpus_used", Labels: []string{"tenant", "tenant_id"}},
{Name: "limits_memory_max", Labels: []string{"tenant", "tenant_id"}},
{Name: "limits_memory_used", Labels: []string{"tenant", "tenant_id"}},
}

func NewNovaExporter(client *gophercloud.ServiceClient, prefix string, disabledMetrics []string) (*NovaExporter, error) {
Expand Down Expand Up @@ -314,16 +314,16 @@ func ListComputeLimits(exporter *BaseOpenStackExporter, ch chan<- prometheus.Met
}

ch <- prometheus.MustNewConstMetric(exporter.Metrics["limits_vcpus_max"].Metric,
prometheus.GaugeValue, float64(limits.Absolute.MaxTotalCores), p.Name)
prometheus.GaugeValue, float64(limits.Absolute.MaxTotalCores), p.Name, p.ID)

ch <- prometheus.MustNewConstMetric(exporter.Metrics["limits_vcpus_used"].Metric,
prometheus.GaugeValue, float64(limits.Absolute.TotalCoresUsed), p.Name)
prometheus.GaugeValue, float64(limits.Absolute.TotalCoresUsed), p.Name, p.ID)

ch <- prometheus.MustNewConstMetric(exporter.Metrics["limits_memory_max"].Metric,
prometheus.GaugeValue, float64(limits.Absolute.MaxTotalRAMSize), p.Name)
prometheus.GaugeValue, float64(limits.Absolute.MaxTotalRAMSize), p.Name, p.ID)

ch <- prometheus.MustNewConstMetric(exporter.Metrics["limits_memory_used"].Metric,
prometheus.GaugeValue, float64(limits.Absolute.TotalRAMUsed), p.Name)
prometheus.GaugeValue, float64(limits.Absolute.TotalRAMUsed), p.Name, p.ID)
}

return nil
Expand Down

0 comments on commit c99b822

Please sign in to comment.