mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-11-10 08:57:25 +01:00
Fix stats assignments
-Frontend now renders plots correctly
This commit is contained in:
parent
a26f78929b
commit
4ea688817e
@ -25,8 +25,8 @@ func (idb *InfluxDBv2DataRepository) Init(url string, token string, renamings ma
|
|||||||
|
|
||||||
idb.client = influxdb2.NewClientWithOptions(url, token, influxdb2.DefaultOptions().SetTLSConfig(&tls.Config {InsecureSkipVerify: true,} ))
|
idb.client = influxdb2.NewClientWithOptions(url, token, influxdb2.DefaultOptions().SetTLSConfig(&tls.Config {InsecureSkipVerify: true,} ))
|
||||||
idb.queryClient = idb.client.QueryAPI("ClusterCockpit") // Influxdb Org here
|
idb.queryClient = idb.client.QueryAPI("ClusterCockpit") // Influxdb Org here
|
||||||
idb.bucket = "ClusterCockpit/data"
|
idb.bucket = "ClusterCockpit/data" // New line protocoll: define for requested cluster(s) in loadData, e.g. fritz
|
||||||
idb.measurement = "data"
|
idb.measurement = "data" // New line protocoll: define for each metric in loadData
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ func (idb *InfluxDBv2DataRepository) LoadData(job *schema.Job, metrics []string,
|
|||||||
if ( host == "" || host != row.ValueByKey("host").(string) || rows.TableChanged() ) {
|
if ( host == "" || host != row.ValueByKey("host").(string) || rows.TableChanged() ) {
|
||||||
|
|
||||||
if ( host != "" ) { // Not in initial loop
|
if ( host != "" ) { // Not in initial loop
|
||||||
log.Println(fmt.Sprintf("<< Save Series for : Field %s @ Host %s >>", field, host))
|
// log.Println(fmt.Sprintf("<< Save Series for : Field %s @ Host %s >>", field, host))
|
||||||
jobData[field][scope].Series = append(jobData[field][scope].Series, hostSeries) // add filled data to jobData **before resetting** for new field or new host
|
jobData[field][scope].Series = append(jobData[field][scope].Series, hostSeries) // add filled data to jobData **before resetting** for new field or new host
|
||||||
}
|
}
|
||||||
// (Re-)Set new Series
|
// (Re-)Set new Series
|
||||||
@ -148,7 +148,7 @@ func (idb *InfluxDBv2DataRepository) LoadData(job *schema.Job, metrics []string,
|
|||||||
Statistics: nil,
|
Statistics: nil,
|
||||||
Data: make([]schema.Float, 0),
|
Data: make([]schema.Float, 0),
|
||||||
}
|
}
|
||||||
log.Println(fmt.Sprintf("<< New Series for : Field %s @ Host %s >>", field, host))
|
// log.Println(fmt.Sprintf("<< New Series for : Field %s @ Host %s >>", field, host))
|
||||||
}
|
}
|
||||||
|
|
||||||
val := row.Value().(float64)
|
val := row.Value().(float64)
|
||||||
@ -156,41 +156,38 @@ func (idb *InfluxDBv2DataRepository) LoadData(job *schema.Job, metrics []string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Append last state also
|
// Append last state also
|
||||||
log.Println(fmt.Sprintf("<< Save Final Series for : Field %s @ Host %s >>", field, host))
|
// log.Println(fmt.Sprintf("<< Save Final Series for : Field %s @ Host %s >>", field, host))
|
||||||
jobData[field][scope].Series = append(jobData[field][scope].Series, hostSeries)
|
jobData[field][scope].Series = append(jobData[field][scope].Series, hostSeries)
|
||||||
|
|
||||||
log.Println("<< LOAD STATS >>")
|
|
||||||
|
|
||||||
stats, err := idb.LoadStats(job, metrics, ctx)
|
stats, err := idb.LoadStats(job, metrics, ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("<< LOAD STATS ERROR >>")
|
log.Println("<< LOAD STATS THREW AN ERROR >>")
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for metric, nodes := range stats {
|
for metric, nodes := range stats {
|
||||||
log.Println(fmt.Sprintf("<< Add Stats for : Field %s >>", metric))
|
// log.Println(fmt.Sprintf("<< Add Stats for : Field %s >>", metric))
|
||||||
jobMetric := jobData[metric]
|
|
||||||
for node, stats := range nodes {
|
for node, stats := range nodes {
|
||||||
log.Println(fmt.Sprintf("<< Add Stats for : Host %s : Min %f, Max %f, Avg %f >>", node, stats.Min, stats.Max, stats.Avg ))
|
// log.Println(fmt.Sprintf("<< Add Stats for : Host %s : Min %.2f, Max %.2f, Avg %.2f >>", node, stats.Min, stats.Max, stats.Avg ))
|
||||||
for _, series := range jobMetric[scope].Series {
|
for index, _ := range jobData[metric][scope].Series {
|
||||||
log.Println(fmt.Sprintf("<< Add Stats to Series of: Host %s >>", series.Hostname))
|
// log.Println(fmt.Sprintf("<< Try to add Stats to Series in Position %d >>", index))
|
||||||
if series.Hostname == node {
|
if jobData[metric][scope].Series[index].Hostname == node {
|
||||||
series.Statistics = &stats
|
// log.Println(fmt.Sprintf("<< Match for Series in Position %d : Host %s >>", index, jobData[metric][scope].Series[index].Hostname))
|
||||||
|
jobData[metric][scope].Series[index].Statistics = &schema.MetricStatistics{Avg: stats.Avg, Min: stats.Min, Max: stats.Max}
|
||||||
|
// log.Println(fmt.Sprintf("<< Result Inner: Min %.2f, Max %.2f, Avg %.2f >>", jobData[metric][scope].Series[index].Statistics.Min, jobData[metric][scope].Series[index].Statistics.Max, jobData[metric][scope].Series[index].Statistics.Avg))
|
||||||
}
|
}
|
||||||
// SEGFAULT wegen dieser Logline
|
|
||||||
// log.Println(fmt.Sprintf("<< Result Inner: Min %f, Max %f, Avg %f >>", *series.Statistics.Min, *series.Statistics.Max, *series.Statistics.Avg))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// log.Println(fmt.Sprintf("<< Result Outer for %s: Min %f, Max %f, Avg %f >>",
|
// // DEBUG:
|
||||||
// jobData["clock"][scope].Series[0].Hostname, jobData["clock"][scope].Series[0].Statistics.Min,
|
for _, met := range metrics {
|
||||||
// jobData["clock"][scope].Series[0].Statistics.Max, jobData["clock"][scope].Series[0].Statistics.Avg))
|
for _, series := range jobData[met][scope].Series {
|
||||||
|
log.Println(fmt.Sprintf("<< Result: %d data points for metric %s on %s, Stats: Min %.2f, Max %.2f, Avg %.2f >>",
|
||||||
// log.Println("<< FINAL JOBDATA : CLOCK >>")
|
len(series.Data), met, series.Hostname,
|
||||||
// log.Println(jobData["clock"])
|
series.Statistics.Min, series.Statistics.Max, series.Statistics.Avg))
|
||||||
// log.Println("<< FINAL JOBDATA : CLOCK : NODE >>")
|
}
|
||||||
// log.Println(jobData["clock"][scope])
|
}
|
||||||
|
|
||||||
return jobData, nil
|
return jobData, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user