Skip to content

Commit

Permalink
Merge pull request #345 from Altinity/dev-vladislav
Browse files Browse the repository at this point in the history
introduce verbosity level for exporter
  • Loading branch information
sunsingerus authored Apr 15, 2020
2 parents f4314ba + 2e200d4 commit 123af1d
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 71 deletions.
14 changes: 7 additions & 7 deletions grafana-dashboard/Altinity_ClickHouse_Operator_dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"gnetId": 882,
"graphTooltip": 1,
"id": null,
"iteration": 1586247624124,
"iteration": 1586668145107,
"links": [],
"panels": [
{
Expand Down Expand Up @@ -769,7 +769,7 @@
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Query",
"title": "Queries",
"tooltip": {
"msResolution": false,
"shared": true,
Expand All @@ -787,7 +787,7 @@
"yaxes": [
{
"format": "short",
"label": "queries / sec",
"label": "",
"logBase": 1,
"max": null,
"min": null,
Expand Down Expand Up @@ -899,7 +899,7 @@
"yaxes": [
{
"format": "bytes",
"label": "bytes / sec",
"label": "",
"logBase": 1,
"max": null,
"min": null,
Expand Down Expand Up @@ -2085,7 +2085,7 @@
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Zookeeper Requests in fly",
"title": "Zookeeper Requests",
"tooltip": {
"msResolution": false,
"shared": true,
Expand Down Expand Up @@ -2190,7 +2190,7 @@
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Read/Write syscalls in fly",
"title": "Read/Write syscalls",
"tooltip": {
"msResolution": false,
"shared": true,
Expand Down Expand Up @@ -2300,7 +2300,7 @@
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Marks Cache Efficiency 1 min",
"title": "Marks Cache Hit Rate",
"tooltip": {
"msResolution": false,
"shared": true,
Expand Down
36 changes: 18 additions & 18 deletions pkg/apis/metrics/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (e *Exporter) getWatchedCHIs() []*WatchedCHI {
// Collect implements prometheus.Collector Collect method
func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
if ch == nil {
log.Info("Prometheus channel is closed. Skipping")
log.V(2).Info("Prometheus channel is closed. Skipping")
return
}

Expand All @@ -79,13 +79,13 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
case *WatchedCHI:
e.toRemoveFromWatched.Delete(key)
e.removeFromWatched(key.(*WatchedCHI))
log.Infof("Removed ClickHouseInstallation (%s/%s) from Exporter", key.(*WatchedCHI).Name, key.(*WatchedCHI).Namespace)
log.V(1).Infof("Removed ClickHouseInstallation (%s/%s) from Exporter", key.(*WatchedCHI).Name, key.(*WatchedCHI).Namespace)
}
return true
})
}()

log.Info("Starting Collect")
log.V(2).Info("Starting Collect")
var wg = sync.WaitGroup{}
e.WalkWatchedChi(func(chi *WatchedCHI, hostname string) {
wg.Add(1)
Expand All @@ -95,7 +95,7 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
}(chi, hostname, ch)
})
wg.Wait()
log.Info("Finished Collect")
log.V(2).Info("Finished Collect")
}

func (e *Exporter) enqueueToRemoveFromWatched(chi *WatchedCHI) {
Expand Down Expand Up @@ -143,7 +143,7 @@ func (e *Exporter) updateWatched(chi *WatchedCHI) {
}

// CHI is not watched
log.Infof("Added ClickHouseInstallation (%s/%s): including hostnames into Exporter", chi.Namespace, chi.Name)
log.V(1).Infof("Added ClickHouseInstallation (%s/%s): including hostnames into Exporter", chi.Namespace, chi.Name)

e.chInstallations[chi.indexKey()] = chi
}
Expand All @@ -168,53 +168,53 @@ func (e *Exporter) collectFromHost(chi *WatchedCHI, hostname string, c chan<- pr
fetcher := e.newFetcher(hostname)
writer := NewPrometheusWriter(c, chi, hostname)

log.Infof("Querying metrics for %s\n", hostname)
log.V(2).Infof("Querying metrics for %s\n", hostname)
if metrics, err := fetcher.getClickHouseQueryMetrics(); err == nil {
log.Infof("Extracted %d metrics for %s\n", len(metrics), hostname)
log.V(2).Infof("Extracted %d metrics for %s\n", len(metrics), hostname)
writer.WriteMetrics(metrics)
writer.WriteOKFetch("system.metrics")
} else {
// In case of an error fetching data from clickhouse store CHI name in e.cleanup
log.Infof("Error querying metrics for %s: %s\n", hostname, err)
log.V(2).Infof("Error querying metrics for %s: %s\n", hostname, err)
writer.WriteErrorFetch("system.metrics")
//e.enqueueToRemoveFromWatched(chi)
return
}

log.Infof("Querying table sizes for %s\n", hostname)
log.V(2).Infof("Querying table sizes for %s\n", hostname)
if tableSizes, err := fetcher.getClickHouseQueryTableSizes(); err == nil {
log.Infof("Extracted %d table sizes for %s\n", len(tableSizes), hostname)
log.V(2).Infof("Extracted %d table sizes for %s\n", len(tableSizes), hostname)
writer.WriteTableSizes(tableSizes)
writer.WriteOKFetch("table sizes")
} else {
// In case of an error fetching data from clickhouse store CHI name in e.cleanup
log.Infof("Error querying table sizes for %s: %s\n", hostname, err)
log.V(2).Infof("Error querying table sizes for %s: %s\n", hostname, err)
writer.WriteErrorFetch("table sizes")
// e.enqueueToRemoveFromWatched(chi)
return
}

log.Infof("Querying system replicas for %s\n", hostname)
log.V(2).Infof("Querying system replicas for %s\n", hostname)
if systemReplicas, err := fetcher.getClickHouseQuerySystemReplicas(); err == nil {
log.Infof("Extracted %d system replicas for %s\n", len(systemReplicas), hostname)
log.V(2).Infof("Extracted %d system replicas for %s\n", len(systemReplicas), hostname)
writer.WriteSystemReplicas(systemReplicas)
writer.WriteOKFetch("system.replicas")
} else {
// In case of an error fetching data from clickhouse store CHI name in e.cleanup
log.Infof("Error querying system replicas for %s: %s\n", hostname, err)
log.V(2).Infof("Error querying system replicas for %s: %s\n", hostname, err)
writer.WriteErrorFetch("system.replicas")
// e.enqueueToRemoveFromWatched(chi)
return
}

log.Infof("Querying mutations for %s\n", hostname)
log.V(2).Infof("Querying mutations for %s\n", hostname)
if mutations, err := fetcher.getClickHouseQueryMutations(); err == nil {
log.Infof("Extracted %d mutations for %s\n", len(mutations), hostname)
log.V(2).Infof("Extracted %d mutations for %s\n", len(mutations), hostname)
writer.WriteMutations(mutations)
writer.WriteOKFetch("system.mutations")
} else {
// In case of an error fetching data from clickhouse store CHI name in e.cleanup
log.Infof("Error querying mutations for %s: %s\n", hostname, err)
log.V(2).Infof("Error querying mutations for %s: %s\n", hostname, err)
writer.WriteErrorFetch("system.mutations")
//e.enqueueToRemoveFromWatched(chi)
return
Expand Down Expand Up @@ -275,7 +275,7 @@ func (e *Exporter) DiscoveryWatchedCHIs(chop *chop.CHOp, chopClient *chopclients
// Walk over the list of ClickHouseInstallation objects and add them as watched
for i := range list.Items {
chi := &list.Items[i]
log.Infof("Adding explicitly found CHI %s/%s with %d hosts\n", chi.Namespace, chi.Name, len(chi.Status.FQDNs))
log.V(1).Infof("Adding explicitly found CHI %s/%s with %d hosts\n", chi.Namespace, chi.Name, len(chi.Status.FQDNs))
watchedCHI := &WatchedCHI{
Namespace: chi.Namespace,
Name: chi.Name,
Expand Down
18 changes: 9 additions & 9 deletions pkg/chop/chop.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,31 @@ func (c *CHOp) Config() *v1.OperatorConfig {
func (c *CHOp) SetupLog() {
updated := false
if c.Config().Logtostderr != "" {
log.Infof("Log option cur value %s=%s\n", "logtostderr", flag.Lookup("logtostderr").Value)
log.Infof("Log option new value %s=%s\n", "logtostderr", c.Config().Logtostderr)
log.V(1).Infof("Log option cur value %s=%s\n", "logtostderr", flag.Lookup("logtostderr").Value)
log.V(1).Infof("Log option new value %s=%s\n", "logtostderr", c.Config().Logtostderr)
updated = true
_ = flag.Set("logtostderr", c.Config().Logtostderr)
}
if c.Config().Alsologtostderr != "" {
log.Infof("Log option cur value %s=%s\n", "alsologtostderr", flag.Lookup("alsologtostderr").Value)
log.Infof("Log option new value %s=%s\n", "alsologtostderr", c.Config().Alsologtostderr)
log.V(1).Infof("Log option cur value %s=%s\n", "alsologtostderr", flag.Lookup("alsologtostderr").Value)
log.V(1).Infof("Log option new value %s=%s\n", "alsologtostderr", c.Config().Alsologtostderr)
updated = true
_ = flag.Set("alsologtostderr", c.Config().Alsologtostderr)
}
if c.Config().Stderrthreshold != "" {
log.Infof("Log option cur value %s=%s\n", "stderrthreshold", flag.Lookup("stderrthreshold").Value)
log.Infof("Log option new value %s=%s\n", "stderrthreshold", c.Config().Stderrthreshold)
log.V(1).Infof("Log option cur value %s=%s\n", "stderrthreshold", flag.Lookup("stderrthreshold").Value)
log.V(1).Infof("Log option new value %s=%s\n", "stderrthreshold", c.Config().Stderrthreshold)
updated = true
_ = flag.Set("stderrthreshold", c.Config().Stderrthreshold)
}
if c.Config().V != "" {
log.Infof("Log option cur value %s=%s\n", "v", flag.Lookup("v").Value)
log.Infof("Log option new value %s=%s\n", "v", c.Config().V)
log.V(1).Infof("Log option cur value %s=%s\n", "v", flag.Lookup("v").Value)
log.V(1).Infof("Log option new value %s=%s\n", "v", c.Config().V)
updated = true
_ = flag.Set("v", c.Config().V)
}

if updated {
log.Infof("Additional log options applied\n")
log.V(1).Infof("Additional log options applied\n")
}
}
Loading

0 comments on commit 123af1d

Please sign in to comment.