-
-
Notifications
You must be signed in to change notification settings - Fork 7
feat: enable built in Prometheus servlet #695
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3f0d9a3
remove jmx agent and metrics ports
razvan 759f887
enable prometheus endpoint
razvan 11d6276
Revert "remove jmx agent and metrics ports"
razvan deae3b9
add test and update docs
razvan 43f1529
update changelog
razvan 3d14a50
Update docs/modules/hdfs/pages/usage-guide/monitoring.adoc
razvan 9bc3d3b
review feedback
razvan 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 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
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
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
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,105 @@ | ||
# Fetch metrics from the built-in Prometheus endpoint of HDFS components. | ||
|
||
import logging | ||
import re | ||
import sys | ||
|
||
import requests | ||
|
||
|
||
def check_metrics( | ||
namespace: str, role: str, port: int, expected_metrics: list[str] | ||
) -> None: | ||
response: requests.Response = requests.get( | ||
f"http://hdfs-{role}-default-0.hdfs-{role}-default.{namespace}.svc.cluster.local:{port}/prom", | ||
timeout=10, | ||
) | ||
assert response.ok, "Requesting metrics failed" | ||
|
||
for metric in expected_metrics: | ||
assert re.search(f"^{metric}", response.text, re.MULTILINE) is not None, ( | ||
f"Metric '{metric}' not found for {role}" | ||
) | ||
|
||
|
||
def check_namenode_metrics( | ||
namespace: str, | ||
product_version: str, | ||
) -> None: | ||
expected_metrics: list[str] = [ | ||
# Kind "MetricsSystem" | ||
'metrics_system_num_active_sources{context="metricssystem",hostname="hdfs-namenode-default-0"}', | ||
# Counter suffixed with "_total" | ||
# The metric attributes can change so use .* for them. | ||
# The full name looks like: 'fs_namesystem_files_total{context="dfs",enabledecpolicies="RS-6-3-1024k",hastate="active",totalsynctimes="4 7 ",hostname="hdfs-namenode-default-0"}', | ||
"fs_namesystem_files_total.*", | ||
# Metric suffixed with "_created" | ||
'namenode_files_created{processname="NameNode",sessionid="null",context="dfs",hostname="hdfs-namenode-default-0"}', | ||
# Boolean metric | ||
# 'hadoop_namenode_security_enabled{kind="NameNodeStatus",role="NameNode",service="HDFS"}', | ||
# Non-special metric | ||
'namenode_files_deleted{processname="NameNode",sessionid="null",context="dfs",hostname="hdfs-namenode-default-0"}', | ||
] | ||
|
||
check_metrics(namespace, "namenode", 9870, expected_metrics) | ||
|
||
|
||
def check_datanode_metrics( | ||
namespace: str, | ||
product_version: str, | ||
) -> None: | ||
expected_metrics: list[str] = [ | ||
# Kind "MetricsSystem" | ||
'metrics_system_num_active_sources{context="metricssystem",hostname="hdfs-datanode-default-0"}', | ||
# Kind "FSDatasetState" suffixed with "_total" | ||
# 'org_apache_hadoop_hdfs_server_datanode_fsdataset_impl_fs_dataset_impl_estimated_capacity_lost_total{context="FSDatasetState",storageinfo="FSDataset{dirpath=\'[/stackable/data/hdd/datanode,/stackable/data/hdd-1/datanode, /stackable/data/ssd/datanode]\'}",hostname="hdfs-datanode-default-0"}', | ||
"org_apache_hadoop_hdfs_server_datanode_fsdataset_impl_fs_dataset_impl_estimated_capacity_lost_total.*", | ||
# Kind "FSDatasetState" | ||
# 'org_apache_hadoop_hdfs_server_datanode_fsdataset_impl_fs_dataset_impl_capacity{context="FSDatasetState",storageinfo="FSDataset{dirpath=\'[/stackable/data/hdd/datanode, /stackable/data/hdd-1/datanode, /stackable/data/ssd/datanode]\'}",hostname="hdfs-datanode-default-0"}', | ||
"org_apache_hadoop_hdfs_server_datanode_fsdataset_impl_fs_dataset_impl_capacity.*", | ||
# Kind "DataNodeActivity" suffixed with "_info" | ||
'datanode_blocks_get_local_path_info{sessionid="null",context="dfs",hostname="hdfs-datanode-default-0"}', | ||
# Kind "DataNodeActivity" | ||
'datanode_blocks_read{sessionid="null",context="dfs",hostname="hdfs-datanode-default-0"}', | ||
# Counter suffixed with "_total" | ||
# 'org_apache_hadoop_hdfs_server_datanode_fsdataset_impl_fs_dataset_impl_estimated_capacity_lost_total{context="FSDatasetState",storageinfo="FSDataset{dirpath=\'[/stackable/data/hdd/datanode,/stackable/data/hdd-1/datanode, /stackable/data/ssd/datanode]\'}",hostname="hdfs-datanode-default-0"}', | ||
"org_apache_hadoop_hdfs_server_datanode_fsdataset_impl_fs_dataset_impl_estimated_capacity_lost_total.*", | ||
# Boolean metric | ||
#'hadoop_datanode_security_enabled{kind="DataNodeInfo",role="DataNode",service="HDFS"}', | ||
# Non-special metric | ||
'jvm_metrics_gc_count{context="jvm",processname="DataNode",sessionid="null",hostname="hdfs-datanode-default-0"}', | ||
] | ||
|
||
check_metrics(namespace, "datanode", 9864, expected_metrics) | ||
|
||
|
||
def check_journalnode_metrics( | ||
namespace: str, | ||
product_version: str, | ||
) -> None: | ||
expected_metrics: list[str] = [ | ||
# Kind "MetricsSystem" | ||
'metrics_system_num_active_sources{context="metricssystem",hostname="hdfs-journalnode-default-0"}', | ||
# Non-special metric | ||
'journal_node_bytes_written{context="dfs",journalid="hdfs",hostname="hdfs-journalnode-default-0"}', | ||
# There is no boolean metric in JournalNode. | ||
] | ||
|
||
check_metrics(namespace, "journalnode", 8480, expected_metrics) | ||
|
||
|
||
if __name__ == "__main__": | ||
namespace_arg: str = sys.argv[1] | ||
product_version_arg: str = sys.argv[2] | ||
|
||
logging.basicConfig( | ||
level="DEBUG", | ||
format="%(asctime)s %(levelname)s: %(message)s", | ||
stream=sys.stdout, | ||
) | ||
|
||
check_namenode_metrics(namespace_arg, product_version_arg) | ||
check_datanode_metrics(namespace_arg, product_version_arg) | ||
check_journalnode_metrics(namespace_arg, product_version_arg) | ||
|
||
print("All expected metrics found") |
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.
Uh oh!
There was an error while loading. Please reload this page.