Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add last high state date/time to grid screen; fade stale grid metrics… #310

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/clientparameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,6 @@ func (params *CaseParameters) Verify() error {
}

type GridParameters struct {
MaxUploadSize uint64 `json:"maxUploadSize,omitempty"`
MaxUploadSize uint64 `json:"maxUploadSize,omitempty"`
StaleMetricsMs uint64 `json:"staleMetricsMs,omitempty"`
}
4 changes: 4 additions & 0 deletions html/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
max-width: 300px;
}

.stale {
opacity: 0.3;
}

/* animations */
.waggle {
animation-name: waggle;
Expand Down
65 changes: 36 additions & 29 deletions html/index.html

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions html/js/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ const i18n = {
keywords: 'Filter Keywords',
kind: 'Kind',
last: 'Last',
lastHighstate: 'Last Synchronized',
lastName: 'Last Name',
length: 'Length',
license: 'License',
Expand Down Expand Up @@ -461,6 +462,7 @@ const i18n = {
logoutFailure: 'Unable to initiate logout. Ensure server is accessible.',
markdownFormattingSupported: 'Markdown formatting supported',
maximize: 'Maximize View (ESC to cancel)',
maxUploadSize: 'Maximum upload size',
mbps: 'Mb/s',
md5: 'MD5',
memUsage: 'Memory Usage',
Expand Down
11 changes: 10 additions & 1 deletion html/js/routes/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ routes.push({ path: '/grid', name: 'grid', component: {
gridMemberUploadConfirmDialog: false,
uploadForm: { valid: true, attachment: null },
maxUploadSizeBytes: 25 * 1024 * 1024,
staleMetricsMs: 120000,
rules: {
fileSizeLimit: value => (value == null || value.size < this.maxUploadSizeBytes) || this.$root.i18n.fileTooLarge.replace("{maxUploadSizeBytes}", this.$root.formatCount(this.maxUploadSizeBytes)),
fileNotEmpty: value => (value == null || value.size > 0) || this.$root.i18n.fileEmpty,
Expand Down Expand Up @@ -90,6 +91,9 @@ routes.push({ path: '/grid', name: 'grid', component: {
if (params.maxUploadSize) {
this.maxUploadSizeBytes = params.maxUploadSize;
}
if (params.staleMetricsMs) {
this.staleMetricsMs = params.staleMetricsMs;
}

this.zone = moment.tz.guess();

Expand Down Expand Up @@ -124,7 +128,12 @@ routes.push({ path: '/grid', name: 'grid', component: {
column.align = ' d-none ' + size;
}
}

},
areMetricsCurrent(node) {
const lastUpdated = Date.parse(node["updateTime"]);
const now = Date.now();
const age = now - lastUpdated;
return age < this.staleMetricsMs;
},
updateMetricsEnabled() {
this.metricsEnabled = !this.nodes.every(function(node) { return !node.metricsEnabled; });
Expand Down
1 change: 1 addition & 0 deletions model/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type Node struct {
Load15m float64 `json:"load15m"`
DiskUsedElasticGB float64 `json:"diskUsedElasticGB"`
DiskUsedInfluxDbGB float64 `json:"diskUsedInfluxDbGB"`
HighstateAgeSeconds int `json:"highstateAgeSeconds"`
}

func NewNode(id string) *Node {
Expand Down
3 changes: 3 additions & 0 deletions server/modules/influxdb/influxdbmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type InfluxDBMetrics struct {
load15m map[string]float64
diskUsedElasticGB map[string]float64
diskUsedInfluxDbGB map[string]float64
highstateAgeSeconds map[string]int
}

func NewInfluxDBMetrics(srv *server.Server) *InfluxDBMetrics {
Expand Down Expand Up @@ -325,6 +326,7 @@ func (metrics *InfluxDBMetrics) updateOsStatus() {
metrics.load15m = metrics.convertValuesToFloat64(metrics.fetchLatestValuesByHost("system", "load15", "", ""), identity)
metrics.diskUsedElasticGB = metrics.convertValuesToFloat64(metrics.fetchLatestValuesByHost("elasticsearch_indices", "store_size_in_bytes", "", ""), bytesToGB)
metrics.diskUsedInfluxDbGB = metrics.convertValuesToFloat64(metrics.fetchLatestValuesByHost("influxsize", "kbytes", "", ""), KBToGB)
metrics.highstateAgeSeconds = metrics.convertValuesToInt(metrics.fetchLatestValuesByHost("salt", "highstate_age_seconds", "", ""))

metrics.lastOsUpdateTime = now
}
Expand Down Expand Up @@ -487,6 +489,7 @@ func (metrics *InfluxDBMetrics) UpdateNodeMetrics(ctx context.Context, node *mod
node.Load15m = metrics.load15m[node.Id]
node.DiskUsedElasticGB = metrics.diskUsedElasticGB[node.Id]
node.DiskUsedInfluxDbGB = metrics.diskUsedInfluxDbGB[node.Id]
node.HighstateAgeSeconds = metrics.highstateAgeSeconds[node.Id]

enhancedStatusEnabled := (metrics.client != nil)
status = node.UpdateOverallStatus(enhancedStatusEnabled)
Expand Down
Loading