-
Notifications
You must be signed in to change notification settings - Fork 615
HDDS-13133. Display Ratis state machine event timeline in OM web UI #10034
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
Changes from all commits
4beed12
bb7017c
f34f9c1
c5c1df2
b91c045
bb11061
fc5419f
fee200a
8471458
99cce18
d5ddbeb
c6d143e
661ddc2
22f30f4
237733b
d0750f1
778681b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,13 +17,17 @@ | |
|
|
||
| package org.apache.hadoop.hdds.scm.container.placement.metrics; | ||
|
|
||
| import java.util.LinkedList; | ||
| import org.apache.hadoop.hdds.conf.ConfigurationSource; | ||
| import org.apache.hadoop.hdds.scm.ScmConfigKeys; | ||
| import org.apache.hadoop.hdds.utils.DBCheckpointMetrics; | ||
| import org.apache.hadoop.metrics2.MetricsSystem; | ||
| import org.apache.hadoop.metrics2.annotation.Metric; | ||
| import org.apache.hadoop.metrics2.annotation.Metrics; | ||
| import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; | ||
| import org.apache.hadoop.metrics2.lib.MutableCounterLong; | ||
| import org.apache.hadoop.metrics2.lib.MutableGaugeLong; | ||
| import org.apache.hadoop.util.Time; | ||
|
|
||
| /** | ||
| * This class is for maintaining StorageContainerManager statistics. | ||
|
|
@@ -33,6 +37,9 @@ public class SCMMetrics { | |
| public static final String SOURCE_NAME = | ||
| SCMMetrics.class.getSimpleName(); | ||
|
|
||
| private final LinkedList<String> ratisEvents = new LinkedList<>(); | ||
| private final int maxRatisEvents; | ||
|
|
||
| /** | ||
| * Container stat metrics, the meaning of following metrics | ||
| * can be found in {@link ContainerStat}. | ||
|
|
@@ -59,14 +66,23 @@ public DBCheckpointMetrics getDBCheckpointMetrics() { | |
| return dbCheckpointMetrics; | ||
| } | ||
|
|
||
| public SCMMetrics() { | ||
| public SCMMetrics(int maxRatisEvents) { | ||
| dbCheckpointMetrics = DBCheckpointMetrics.create("SCM Metrics"); | ||
| this.maxRatisEvents = maxRatisEvents; | ||
| } | ||
|
|
||
| public static SCMMetrics create() { | ||
| return create(null); | ||
| } | ||
|
|
||
| public static SCMMetrics create(ConfigurationSource conf) { | ||
| MetricsSystem ms = DefaultMetricsSystem.instance(); | ||
| int maxRatisEvents = conf == null | ||
| ? ScmConfigKeys.OZONE_SCM_RATIS_EVENTS_MAX_LIMIT_DEFAULT | ||
| : conf.getInt(ScmConfigKeys.OZONE_SCM_RATIS_EVENTS_MAX_LIMIT, | ||
| ScmConfigKeys.OZONE_SCM_RATIS_EVENTS_MAX_LIMIT_DEFAULT); | ||
| return ms.register(SOURCE_NAME, "Storage Container Manager Metrics", | ||
| new SCMMetrics()); | ||
| new SCMMetrics(maxRatisEvents)); | ||
| } | ||
|
|
||
| public void setLastContainerReportSize(long size) { | ||
|
|
@@ -155,6 +171,22 @@ public void decrContainerStat(ContainerStat deltaStat) { | |
| this.containerReportWriteCount.incr(-1 * deltaStat.getWriteCount().get()); | ||
| } | ||
|
|
||
| public void addRatisEvent(String event) { | ||
| synchronized (ratisEvents) { | ||
| if (ratisEvents.size() >= maxRatisEvents) { | ||
| ratisEvents.removeFirst(); | ||
| } | ||
| ratisEvents.add(Time.formatTime(Time.now()) + "|" + event); | ||
| } | ||
| } | ||
|
|
||
| @Metric("Ratis state machine events") | ||
| public String getRatisEvents() { | ||
| synchronized (ratisEvents) { | ||
| return String.join("\n", ratisEvents); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Newlines are invalid separators in Prometheus. This change prevents all SCM metrics from being ingested into Prometheus. @jojochuang we should:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually the streamed Ratis events can have arbitrary content, it's not just the hardcoded separator. It looks like this was never meant to be surfaced to Prometheus or JMX and I don't think we should be tracking Ratis events as metrics at all. We can keep the Linklist and query it from memory elsewhere. Filed HDDS-15552. |
||
| } | ||
| } | ||
|
|
||
| public void unRegister() { | ||
| MetricsSystem ms = DefaultMetricsSystem.instance(); | ||
| ms.unregisterSource(SOURCE_NAME); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <!-- | ||
| Licensed to the Apache Software Foundation (ASF) under one or more | ||
| contributor license agreements. See the NOTICE file distributed with | ||
| this work for additional information regarding copyright ownership. | ||
| The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| (the "License"); you may not use this file except in compliance with | ||
| the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| --> | ||
| <h1>Ratis event timeline</h1> | ||
|
|
||
| <table class="table table-striped"> | ||
| <thead> | ||
| <tr> | ||
| <th class="col-md-3">Timestamp</th> | ||
| <th class="col-md-9">Event description</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <tr ng-repeat="event in $ctrl.events track by $index"> | ||
| <td>{{event.timestamp}}</td> | ||
| <td>{{event.description}}</td> | ||
| </tr> | ||
| </tbody> | ||
| </table> |

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.