Resources
Live system information of a node: resource metrics such as CPU, memory, storage and network interface usage, and the network flows crossing its interfaces. Use this service to monitor the health and traffic of any node.
Open metrics stream
Stream the resource metrics of a node, such as CPU, memory, disk and network interface usage. A sample of the current metrics is sent when the stream opens. The stream stays open until the client closes it, and ends with an error if the node loses its connection.
- REST
- gRPC
/v1/streams/nodes/{node_id}/metricsServer-sent events. A : ready comment is sent when the stream is ready, then each message is a data: line holding the response below. A failure after that is an error event.
node_idstringID of the node to read metrics from.
- TypeScript
- Python
- curl
import { NanopingClient } from "@nanoping/api";
const client = new NanopingClient({ baseUrl: "http://127.0.0.1:10565" });
for await (const response of client.resources.openMetricsStream({
nodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"
})) {
}
from nanoping_api import NanopingClient
client = NanopingClient("http://127.0.0.1:10565")
for response in client.resources.open_metrics_stream(
node_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
):
print(response)
curl -N 'http://127.0.0.1:10565/v1/streams/nodes/<node_id>/metrics'
timestamptimestampWhen the sample was taken.
collectionsCollection[]The metrics, grouped into collections such as
/system/memoryand/system/disk.
rpc openMetricsStream(OpenMetricsStreamRequest) returns (stream MetricsSample)
Method /nanopinggrpc.resources.ResourcesService/openMetricsStream
node_idstringID of the node to read metrics from.
timestamptimestampWhen the sample was taken.
collectionsCollection[]The metrics, grouped into collections such as
/system/memoryand/system/disk.
- Go
- Go (generated gRPC)
import (
client "github.com/nanoping-labs/nanoping-api-go/v11"
"github.com/nanoping-labs/nanoping-api-go/v11/resources"
)
c, err := client.Connect("127.0.0.1:10432")
defer c.Close()
stream, err := c.Resources.OpenMetricsStream(ctx, &resources.OpenMetricsStreamRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
})
for response, err := range client.Receive(stream) {
if err != nil {
return err
}
}
import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"github.com/nanoping-labs/nanoping-api-go/v11/resources"
)
conn, err := grpc.NewClient("127.0.0.1:10432", grpc.WithTransportCredentials(insecure.NewCredentials()))
defer conn.Close()
stub := resources.NewResourcesServiceClient(conn)
stream, err := stub.OpenMetricsStream(ctx, &resources.OpenMetricsStreamRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
})
for {
response, err := stream.Recv()
if err != nil {
return err
}
}
Open flows stream
Stream a snapshot of the network flows crossing the interfaces of a node, about once a second, starting right away. The node only captures packets while someone watches its flows, so the first samples may be empty or incomplete.
- REST
- gRPC
/v1/streams/nodes/{node_id}/flowsServer-sent events. A : ready comment is sent when the stream is ready, then each message is a data: line holding the response below. A failure after that is an error event.
node_idstringID of the node to read flows from.
- TypeScript
- Python
- curl
import { NanopingClient } from "@nanoping/api";
const client = new NanopingClient({ baseUrl: "http://127.0.0.1:10565" });
for await (const response of client.resources.openFlowsStream({
nodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f"
})) {
}
from nanoping_api import NanopingClient
client = NanopingClient("http://127.0.0.1:10565")
for response in client.resources.open_flows_stream(
node_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
):
print(response)
curl -N 'http://127.0.0.1:10565/v1/streams/nodes/<node_id>/flows'
timestamptimestampWhen the snapshot was taken.
flowsFlow[]Every flow the node currently tracks. Empty when none have been captured.
rpc openFlowsStream(OpenFlowsStreamRequest) returns (stream FlowsSample)
Method /nanopinggrpc.resources.ResourcesService/openFlowsStream
node_idstringID of the node to read flows from.
timestamptimestampWhen the snapshot was taken.
flowsFlow[]Every flow the node currently tracks. Empty when none have been captured.
- Go
- Go (generated gRPC)
import (
client "github.com/nanoping-labs/nanoping-api-go/v11"
"github.com/nanoping-labs/nanoping-api-go/v11/resources"
)
c, err := client.Connect("127.0.0.1:10432")
defer c.Close()
stream, err := c.Resources.OpenFlowsStream(ctx, &resources.OpenFlowsStreamRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
})
for response, err := range client.Receive(stream) {
if err != nil {
return err
}
}
import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"github.com/nanoping-labs/nanoping-api-go/v11/resources"
)
conn, err := grpc.NewClient("127.0.0.1:10432", grpc.WithTransportCredentials(insecure.NewCredentials()))
defer conn.Close()
stub := resources.NewResourcesServiceClient(conn)
stream, err := stub.OpenFlowsStream(ctx, &resources.OpenFlowsStreamRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
})
for {
response, err := stream.Recv()
if err != nil {
return err
}
}