mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +01:00
We introduce an leaky abstraction for flows schema and use it for migrations as a first step. For views and dictionaries, we stop relying on a hash to know if they need to be recreated, but we compare the select statements with our target statement. This is a bit fragile, but strictly better than the hash. For data tables, we add the missing columns. We give up on the abstraction of a migration step and just rely on helper functions to get the same result. The migration code is now shorter and we don't need to update it when adding new columns. This is a preparatory work for #211 to allow a user to specify additional fields to collect.
60 lines
1.5 KiB
Go
60 lines
1.5 KiB
Go
// SPDX-FileCopyrightText: 2022 Free Mobile
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
package clickhouse
|
|
|
|
import "akvorado/common/reporter"
|
|
|
|
type metrics struct {
|
|
migrationsRunning reporter.Gauge
|
|
migrationsApplied reporter.Counter
|
|
migrationsNotApplied reporter.Counter
|
|
|
|
networkSourceUpdates *reporter.CounterVec
|
|
networkSourceErrors *reporter.CounterVec
|
|
networkSourceCount *reporter.GaugeVec
|
|
}
|
|
|
|
func (c *Component) initMetrics() {
|
|
c.metrics.migrationsRunning = c.r.Gauge(
|
|
reporter.GaugeOpts{
|
|
Name: "migrations_running",
|
|
Help: "Database migrations in progress.",
|
|
},
|
|
)
|
|
c.metrics.migrationsApplied = c.r.Counter(
|
|
reporter.CounterOpts{
|
|
Name: "migrations_applied_steps",
|
|
Help: "Number of migration steps applied",
|
|
},
|
|
)
|
|
c.metrics.migrationsNotApplied = c.r.Counter(
|
|
reporter.CounterOpts{
|
|
Name: "migrations_notapplied_steps",
|
|
Help: "Number of migration steps not applied",
|
|
},
|
|
)
|
|
|
|
c.metrics.networkSourceUpdates = c.r.CounterVec(
|
|
reporter.CounterOpts{
|
|
Name: "network_source_updates_total",
|
|
Help: "Number of successful updates for a network source",
|
|
},
|
|
[]string{"source"},
|
|
)
|
|
c.metrics.networkSourceErrors = c.r.CounterVec(
|
|
reporter.CounterOpts{
|
|
Name: "network_source_errors_total",
|
|
Help: "Number of failed updates for a network source",
|
|
},
|
|
[]string{"source", "error"},
|
|
)
|
|
c.metrics.networkSourceCount = c.r.GaugeVec(
|
|
reporter.GaugeOpts{
|
|
Name: "network_source_networks_total",
|
|
Help: "Number of networks imported from a given source",
|
|
},
|
|
[]string{"source"},
|
|
)
|
|
}
|