Skip to content

Commit

Permalink
fixes for comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeymyltsev authored and niedbalski committed Apr 27, 2021
1 parent 2814d4d commit a5d0d67
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 37 deletions.
67 changes: 34 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,41 +89,42 @@ The current list of command line options (by running --help)
usage: openstack-exporter [<flags>] <cloud>

Flags:
-h, --help Show context-sensitive help (also try --help-long and --help-man).
--log.level="info" Log level: [debug, info, warn, error, fatal]
--web.listen-address=":9180"
address:port to listen on
--web.telemetry-path="/metrics"
uri path to expose metrics
--os-client-config="/etc/openstack/clouds.yaml"
Path to the cloud configuration file
--prefix="openstack" Prefix for metrics
--endpoint-type="public" Openstack endpoint type to use (i.e: public, internal, admin)
--collect-metric-time Time spent collecting each metric
--disable-deprecated-metrics Disable deprecated metrics
--disable-slow-metrics Disable slow metrics for performance reasons
--multi-cloud Toggle the multiple cloud scraping mode under /probe?cloud=
-d, --disable-metric= ... multiple --disable-metric can be specified in the format: service-metric (i.e: cinder-snapshots)
--disable-service.network Disable the network service exporter
--disable-service.compute Disable the compute service exporter
--disable-service.image Disable the image service exporter
--disable-service.volume Disable the volume service exporter
--disable-service.identity
Disable the identity service exporter
--disable-service.object-store
Disable the object-store service exporter
--disable-service.load-balancer
Disable the load-balancer service exporter
--disable-service.container-infra
Disable the container-infra service exporter
--disable-service.dns Disable the dns service exporter
--disable-service.baremetal
Disable the baremetal service exporter
--disable-service.gnocchi Disable the gnocchi service
--version Show application version.
-h, --help Show context-sensitive help (also try --help-long and --help-man).
--log.level="info" Log level: [debug, info, warn, error, fatal]
--web.listen-address=":9180"
address:port to listen on
--web.telemetry-path="/metrics"
uri path to expose metrics
--os-client-config="/etc/openstack/clouds.yaml"
Path to the cloud configuration file
--prefix="openstack" Prefix for metrics
--endpoint-type="public" openstack endpoint type to use (i.e: public, internal, admin)
--collect-metric-time time spent collecting each metric
-d, --disable-metric= ... multiple --disable-metric can be specified in the format: service-metric (i.e: cinder-snapshots)
--disable-slow-metrics Disable slow metrics for performance reasons
--disable-deprecated-metrics
Disable deprecated metrics
--multi-cloud Toggle the multiple cloud scraping mode under /probe?cloud=
--disable-service.network Disable the network service exporter
--disable-service.compute Disable the compute service exporter
--disable-service.image Disable the image service exporter
--disable-service.volume Disable the volume service exporter
--disable-service.identity
Disable the identity service exporter
--disable-service.object-store
Disable the object-store service exporter
--disable-service.load-balancer
Disable the load-balancer service exporter
--disable-service.container-infra
Disable the container-infra service exporter
--disable-service.dns Disable the dns service exporter
--disable-service.baremetal
Disable the baremetal service exporter
--disable-service.gnocchi Disable the gnocchi service exporter
--version Show application version.

Args:
<cloud> name or id of the cloud to gather metrics from
[<cloud>] name or id of the cloud to gather metrics from
```

### Scrape options
Expand Down
37 changes: 36 additions & 1 deletion exporters/cinder.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var defaultCinderMetrics = []Metric{
{Name: "snapshots", Fn: ListSnapshots},
{Name: "agent_state", Labels: []string{"uuid", "hostname", "service", "adminState", "zone", "disabledReason"}, Fn: ListCinderAgentState},
{Name: "volume_gb", Labels: []string{"id", "name", "status", "bootable", "tenant_id", "volume_type", "server_id"}, Fn: nil},
{Name: "volume_status", Labels: []string{"id", "name", "status", "bootable", "tenant_id", "size", "volume_type", "server_id"}, Fn: nil, Slow: false, DeprecatedVersion: "1.5"},
{Name: "volume_status", Labels: []string{"id", "name", "status", "bootable", "tenant_id", "size", "volume_type", "server_id"}, Fn: ListVolumesStatus, Slow: false, DeprecatedVersion: "1.4"},
{Name: "volume_status_counter", Labels: []string{"status"}, Fn: nil},
{Name: "pool_capacity_free_gb", Labels: []string{"name", "volume_backend_name", "vendor_name"}, Fn: ListCinderPoolCapacityFree},
{Name: "pool_capacity_total_gb", Labels: []string{"name", "volume_backend_name", "vendor_name"}, Fn: nil},
Expand Down Expand Up @@ -86,6 +86,41 @@ func NewCinderExporter(config *ExporterConfig) (*CinderExporter, error) {
return &exporter, nil
}

func ListVolumesStatus(exporter *BaseOpenStackExporter, ch chan<- prometheus.Metric) error {
type VolumeWithExt struct {
volumes.Volume
volumetenants.VolumeTenantExt
}

var allVolumes []VolumeWithExt

allPagesVolumes, err := volumes.List(exporter.Client, volumes.ListOpts{
AllTenants: true,
}).AllPages()
if err != nil {
return err
}

err = volumes.ExtractVolumesInto(allPagesVolumes, &allVolumes)
if err != nil {
return err
}

// Volume status metrics
for _, volume := range allVolumes {
if volume.Attachments != nil && len(volume.Attachments) > 0 {
ch <- prometheus.MustNewConstMetric(exporter.Metrics["volume_status"].Metric,
prometheus.GaugeValue, float64(mapVolumeStatus(volume.Status)), volume.ID, volume.Name,
volume.Status, volume.Bootable, volume.TenantID, strconv.Itoa(volume.Size), volume.VolumeType, volume.Attachments[0].ServerID)
} else {
ch <- prometheus.MustNewConstMetric(exporter.Metrics["volume_status"].Metric,
prometheus.GaugeValue, float64(mapVolumeStatus(volume.Status)), volume.ID, volume.Name,
volume.Status, volume.Bootable, volume.TenantID, strconv.Itoa(volume.Size), volume.VolumeType, "")
}
}
return nil
}

func ListVolumes(exporter *BaseOpenStackExporter, ch chan<- prometheus.Metric) error {
type VolumeWithExt struct {
volumes.Volume
Expand Down
2 changes: 1 addition & 1 deletion exporters/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (exporter *BaseOpenStackExporter) AddMetric(name string, fn ListFunc, label
}

if len(deprecatedVersion) > 0 {
log.Warnf("metric: %s has been deprecated on %s exporter and it will be removed in %s release", name, exporter.Name, deprecatedVersion)
log.Warnf("metric: %s has been deprecated on %s exporter in version %s and it will be removed in next release", name, exporter.Name, deprecatedVersion)
}

if exporter.Metrics == nil {
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ var (
endpointType = kingpin.Flag("endpoint-type", "openstack endpoint type to use (i.e: public, internal, admin)").Default("public").String()
collectTime = kingpin.Flag("collect-metric-time", "time spent collecting each metric").Default("false").Bool()
disabledMetrics = kingpin.Flag("disable-metric", "multiple --disable-metric can be specified in the format: service-metric (i.e: cinder-snapshots)").Default("").Short('d').Strings()
disableSlowMetrics = kingpin.Flag("disable-slow-metrics", "disable slow metrics for performance reasons").Default("false").Bool()
disableDeprecatedMetrics = kingpin.Flag("disable-deprecated-metrics", "disable deprecated metrics").Default("false").Bool()
disableSlowMetrics = kingpin.Flag("disable-slow-metrics", "Disable slow metrics for performance reasons").Default("false").Bool()
disableDeprecatedMetrics = kingpin.Flag("disable-deprecated-metrics", "Disable deprecated metrics").Default("false").Bool()
cloud = kingpin.Arg("cloud", "name or id of the cloud to gather metrics from").String()
multiCloud = kingpin.Flag("multi-cloud", "Toggle the multiple cloud scraping mode under /probe?cloud=").Default("false").Bool()
)
Expand Down

0 comments on commit a5d0d67

Please sign in to comment.