databendlabs/databend · error
Failed to get metrics
Error message
Failed to get metrics: {} What it means
databend-metactl's metrics command runs a Lua script that fetches metrics from a metasrv admin API endpoint. If the script's HTTP call fails or returns an error, the error message is wrapped as 'Failed to get metrics: {}'.
Solutions
- Verify the metasrv node is running and the --admin-api-address matches its configured admin_api_address
- Curl http://<admin-api-address>/v1/health or the metrics path manually to confirm reachability
- Check firewall/DNS between the metactl host and the metasrv node
Example fix
// before metactl metrics --admin-api-address http://localhost:28002 // after (correct admin api port from config) metactl metrics --admin-api-address http://localhost:28102
Defensive patterns
Strategy: validation
Validate before calling
curl -sf http://<admin-api-address>/v1/health && echo ok || echo 'admin api not reachable'
Try / catch
match metactl_metrics(addr).await {
Ok(_) => (),
Err(e) if e.to_string().contains("Failed to get metrics") => eprintln!("check admin api address: {}", e),
Err(e) => return Err(e),
} Prevention
- Cross-check --admin-api-address against the metasrv config admin_api_address
- Health-check the node before running metrics commands
- Avoid proxies on the admin API path
When it happens
Trigger: Running `metactl ... metrics` when the admin API address is wrong, the node is down, the Lua HTTP request returns non-success, or the response body is not valid metrics output.
Common situations: metasrv not running at --admin-api-address; wrong port; network partition; scraping a node whose admin API is disabled or bound differently.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- Lua execution error
- status code: , msg
- invalid peer raft addr
- node id ( ) has to be one of cluster member( )
- Failed to convert RaftStoreEntry to SMEntry
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/43a395c53c716e58.
Report an issue: GitHub.
Appendix: source
Thrown at src/meta/binaries/metactl/main.rs:309
}
async fn get_metrics(&self, args: &MetricsArgs) -> anyhow::Result<()> {
let lua_script = format!(
r#"
local admin_client = metactl.new_admin_client("{}")
local metrics, err = admin_client:metrics()
if err then
return nil, err
end
print(metrics)
return metrics, nil
"#,
args.admin_api_address
);
match lua_support::run_lua_script_with_result(&lua_script).await? {
Ok(_result) => Ok(()),
Err(error_msg) => Err(anyhow::anyhow!("Failed to get metrics: {}", error_msg)),
}
}
async fn member_list(&self, args: &MemberListArgs) -> anyhow::Result<()> {
let addresses = vec![args.grpc_api_address.clone()];
let client = self.new_grpc_client(addresses)?;
let res = client.get_member_list().await?;
for member in res.data {
println!("{}", member);
}
Ok(())
}
fn new_grpc_client(
&self,
addresses: Vec<String>,
) -> Result<Arc<ClientHandle<DatabendRuntime>>, CreationError> {View on GitHub (pinned to 288d84d76e)