-
Notifications
You must be signed in to change notification settings - Fork 986
[JMX Insight] Hadoop jmx metics semconv alignment #14411
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
Open
robsunday
wants to merge
14
commits into
open-telemetry:main
Choose a base branch
from
robsunday:hadoop-jmx-metics-semconv-alignment
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+807
−83
Open
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
889a9c9
Initial commit
robsunday 3b54d6e
Hadoop 2.x and Hadoop 3.x support
robsunday c60c0e5
spotless
robsunday a0c743b
Comments updated
robsunday be3f90c
./gradlew spotlessApply
otelbot[bot] 51c3875
Script fixes
robsunday 579c8fe
Merge remote-tracking branch 'origin/hadoop-jmx-metics-semconv-alignm…
robsunday a4626e7
Script fixes
robsunday 551436c
Exporter port is now ephemeral
robsunday e8b8375
Spotless
robsunday 9c02f4d
Merge branch 'main' into hadoop-jmx-metics-semconv-alignment
robsunday ae462de
Merge branch 'open-telemetry:main' into hadoop-jmx-metics-semconv-ali…
robsunday 6217116
Merge branch 'main' into hadoop-jmx-metics-semconv-alignment
robsunday 01f6503
Merge branch 'hadoop-jmx-metics-semconv-alignment' of github.com:robs…
robsunday File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
63 changes: 0 additions & 63 deletions
63
instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/hadoop.yaml
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Hadoop Metrics | ||
|
||
Here is the list of metrics based on MBeans exposed by Hadoop. | ||
|
||
| Metric Name | Type | Attributes | Description | | ||
|---------------------------------|---------------|-------------------------------------|--------------------------------------------------------| | ||
| hadoop.dfs.capacity | UpDownCounter | hadoop.node.name | Current raw capacity of data nodes. | | ||
| hadoop.dfs.capacity.used | UpDownCounter | hadoop.node.name | Current used capacity across all data nodes. | | ||
| hadoop.dfs.block.count | UpDownCounter | hadoop.node.name | Current number of allocated blocks in the system. | | ||
| hadoop.dfs.block.missing | UpDownCounter | hadoop.node.name | Current number of missing blocks. | | ||
| hadoop.dfs.block.corrupt | UpDownCounter | hadoop.node.name | Current number of blocks with corrupt replicas. | | ||
| hadoop.dfs.volume.failure.count | Counter | hadoop.node.name | Total number of volume failures across all data nodes. | | ||
| hadoop.dfs.file.count | UpDownCounter | hadoop.node.name | Current number of files and directories. | | ||
| hadoop.dfs.connection.count | UpDownCounter | hadoop.node.name | Current number of connection. | | ||
| hadoop.dfs.data_node.count | UpDownCounter | hadoop.node.name, hadoop.node.state | The number of data nodes. | |
71 changes: 71 additions & 0 deletions
71
instrumentation/jmx-metrics/library/src/main/resources/jmx/rules/hadoop.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
rules: | ||
- bean: Hadoop:service=NameNode,name=FSNamesystem | ||
prefix: hadoop.dfs. | ||
metricAttribute: | ||
hadoop.node.name: beanattr(tag\.Hostname) | ||
mapping: | ||
# hadoop.dfs.capacity | ||
CapacityTotal: | ||
metric: capacity | ||
type: updowncounter | ||
unit: By | ||
desc: Current raw capacity of DataNodes. | ||
# hadoop.dfs.capacity.used | ||
CapacityUsed: | ||
metric: capacity.used | ||
type: updowncounter | ||
unit: By | ||
desc: Current used capacity across all DataNodes. | ||
# hadoop.dfs.block.count | ||
BlocksTotal: | ||
metric: block.count | ||
type: updowncounter | ||
unit: "{block}" | ||
desc: Current number of allocated blocks in the system. | ||
# hadoop.dfs.block.missing | ||
MissingBlocks: | ||
metric: block.missing | ||
type: updowncounter | ||
unit: "{block}" | ||
desc: Current number of missing blocks. | ||
# hadoop.dfs.block.corrupt | ||
CorruptBlocks: | ||
metric: block.corrupt | ||
type: updowncounter | ||
unit: "{block}" | ||
desc: Current number of blocks with corrupt replicas. | ||
# hadoop.dfs.volume.failure.count | ||
VolumeFailuresTotal: | ||
metric: volume.failure.count | ||
type: counter | ||
unit: "{failure}" | ||
desc: Total number of volume failures across all DataNodes. | ||
# hadoop.dfs.file.count | ||
FilesTotal: | ||
metric: file.count | ||
type: updowncounter | ||
unit: "{file}" | ||
desc: Current number of files and directories. | ||
# hadoop.dfs.connection.count | ||
TotalLoad: | ||
metric: connection.count | ||
type: updowncounter | ||
unit: "{connection}" | ||
desc: Current number of connections. | ||
|
||
# hadoop.dfs.data_node.count | ||
NumLiveDataNodes: | ||
metric: &metric data_node.count | ||
type: &type updowncounter | ||
unit: &unit "{node}" | ||
desc: &desc The number of DataNodes. | ||
metricAttribute: | ||
hadoop.node.state: const(live) | ||
NumDeadDataNodes: | ||
metric: *metric | ||
type: *type | ||
unit: *unit | ||
desc: *desc | ||
metricAttribute: | ||
hadoop.node.state: const(dead) |
153 changes: 153 additions & 0 deletions
153
...-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/HadoopTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.jmx.rules; | ||
|
||
import static io.opentelemetry.instrumentation.jmx.rules.assertions.DataPointAttributes.attribute; | ||
import static io.opentelemetry.instrumentation.jmx.rules.assertions.DataPointAttributes.attributeGroup; | ||
|
||
import io.opentelemetry.instrumentation.jmx.rules.assertions.AttributeMatcher; | ||
import java.time.Duration; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
import org.testcontainers.utility.MountableFile; | ||
|
||
class HadoopTest extends TargetSystemTest { | ||
@Test | ||
void testMetrics_Hadoop2x() { | ||
List<String> yamlFiles = Collections.singletonList("hadoop.yaml"); | ||
|
||
yamlFiles.forEach(this::validateYamlSyntax); | ||
|
||
// bmedora docker images do not propagate env vars to spanned hadoop processes, | ||
// so everything needs to be embedded inside the hadoop2-env.sh file | ||
GenericContainer<?> target = | ||
new GenericContainer<>("bmedora/hadoop:2.9-base") | ||
.withCopyFileToContainer( | ||
MountableFile.forClasspathResource("hadoop2-env.sh", 0400), | ||
"/hadoop/etc/hadoop/hadoop-env.sh") | ||
.withCreateContainerCmdModifier(cmd -> cmd.withHostName("test-host")) | ||
.withStartupTimeout(Duration.ofMinutes(3)) | ||
.withExposedPorts(50070) | ||
.waitingFor(Wait.forListeningPorts(50070)); | ||
|
||
copyAgentToTarget(target); | ||
copyYamlFilesToTarget(target, yamlFiles); | ||
|
||
startTarget(target); | ||
|
||
verifyMetrics(createMetricsVerifier()); | ||
} | ||
|
||
@Test | ||
void testMetrics_Hadoop3x() { | ||
List<String> yamlFiles = Collections.singletonList("hadoop.yaml"); | ||
|
||
yamlFiles.forEach(this::validateYamlSyntax); | ||
|
||
// Hadoop startup script does not propagate env vars to launched hadoop daemons, | ||
// so all the env vars needs to be embedded inside the hadoop2-env.sh file | ||
GenericContainer<?> target = | ||
new GenericContainer<>("loum/hadoop-pseudo:3.3.6") | ||
.withExposedPorts(9870, 9000) | ||
.withCopyFileToContainer( | ||
MountableFile.forClasspathResource("hadoop3-env.sh", 0644), | ||
"/opt/hadoop/etc/hadoop/hadoop-env.sh") | ||
.withCreateContainerCmdModifier(cmd -> cmd.withHostName("test-host")) | ||
.waitingFor( | ||
Wait.forListeningPorts(9870, 9000).withStartupTimeout(Duration.ofMinutes(3))); | ||
|
||
copyAgentToTarget(target); | ||
copyYamlFilesToTarget(target, yamlFiles); | ||
|
||
startTarget(target); | ||
|
||
verifyMetrics(createMetricsVerifier()); | ||
} | ||
|
||
private static MetricsVerifier createMetricsVerifier() { | ||
AttributeMatcher nodeNameAttribute = attribute("hadoop.node.name", "test-host"); | ||
|
||
return MetricsVerifier.create() | ||
.disableStrictMode() | ||
.add( | ||
"hadoop.dfs.capacity", | ||
metric -> | ||
metric | ||
.hasDescription("Current raw capacity of DataNodes.") | ||
.hasUnit("By") | ||
.isUpDownCounter() | ||
.hasDataPointsWithOneAttribute(nodeNameAttribute)) | ||
.add( | ||
"hadoop.dfs.capacity.used", | ||
metric -> | ||
metric | ||
.hasDescription("Current used capacity across all DataNodes.") | ||
.hasUnit("By") | ||
.isUpDownCounter() | ||
.hasDataPointsWithOneAttribute(nodeNameAttribute)) | ||
.add( | ||
"hadoop.dfs.block.count", | ||
metric -> | ||
metric | ||
.hasDescription("Current number of allocated blocks in the system.") | ||
.hasUnit("{block}") | ||
.isUpDownCounter() | ||
.hasDataPointsWithOneAttribute(nodeNameAttribute)) | ||
.add( | ||
"hadoop.dfs.block.missing", | ||
metric -> | ||
metric | ||
.hasDescription("Current number of missing blocks.") | ||
.hasUnit("{block}") | ||
.isUpDownCounter() | ||
.hasDataPointsWithOneAttribute(nodeNameAttribute)) | ||
.add( | ||
"hadoop.dfs.block.corrupt", | ||
metric -> | ||
metric | ||
.hasDescription("Current number of blocks with corrupt replicas.") | ||
.hasUnit("{block}") | ||
.isUpDownCounter() | ||
.hasDataPointsWithOneAttribute(nodeNameAttribute)) | ||
.add( | ||
"hadoop.dfs.volume.failure.count", | ||
metric -> | ||
metric | ||
.hasDescription("Total number of volume failures across all DataNodes.") | ||
.hasUnit("{failure}") | ||
.isCounter() | ||
.hasDataPointsWithOneAttribute(nodeNameAttribute)) | ||
.add( | ||
"hadoop.dfs.file.count", | ||
metric -> | ||
metric | ||
.hasDescription("Current number of files and directories.") | ||
.hasUnit("{file}") | ||
.isUpDownCounter() | ||
.hasDataPointsWithOneAttribute(nodeNameAttribute)) | ||
.add( | ||
"hadoop.dfs.connection.count", | ||
metric -> | ||
metric | ||
.hasDescription("Current number of connections.") | ||
.hasUnit("{connection}") | ||
.isUpDownCounter() | ||
.hasDataPointsWithOneAttribute(nodeNameAttribute)) | ||
.add( | ||
"hadoop.dfs.data_node.count", | ||
metric -> | ||
metric | ||
.hasDescription("The number of DataNodes.") | ||
.hasUnit("{node}") | ||
.isUpDownCounter() | ||
.hasDataPointsWithAttributes( | ||
attributeGroup(attribute("hadoop.node.state", "live"), nodeNameAttribute), | ||
attributeGroup(attribute("hadoop.node.state", "dead"), nodeNameAttribute))); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[for reviewer] Naming prefix of metrics has been change to utilize a metric context (dfs).
Context is described in official docs: https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-common/Metrics.html