Skip to content

Commit

Permalink
pretty name & parts active condition
Browse files Browse the repository at this point in the history
  • Loading branch information
f1yegor committed Jul 10, 2017
1 parent 9f859ae commit b608398
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions clickhouse_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func NewExporter(uri url.URL) *Exporter {
eventsURI.RawQuery = q.Encode()

partsURI := uri
q.Set("query", "select database, table, sum(bytes) as bytes, count() as parts from system.parts group by database, table")
q.Set("query", "select database, table, sum(bytes) as bytes, count() as parts from system.parts where active = 1 group by database, table")
partsURI.RawQuery = q.Encode()

return &Exporter{
Expand Down Expand Up @@ -158,15 +158,15 @@ func (e *Exporter) collect(ch chan<- prometheus.Metric) error {
for _, part := range parts {
newBytesMetric := prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Name: "clickhouse_table_parts_bytes",
Name: "table_parts_bytes",
Help: "Table size in bytes",
}, []string{"database", "table"}).WithLabelValues(part.database, part.table)
newBytesMetric.Set(float64(part.bytes))
newBytesMetric.Collect(ch)

newCountMetric := prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: namespace,
Name: "clickhouse_table_parts_count",
Name: "table_parts_count",
Help: "Number of parts of the table",
}, []string{"database", "table"}).WithLabelValues(part.database, part.table)
newCountMetric.Set(float64(part.parts))
Expand Down

0 comments on commit b608398

Please sign in to comment.