Logging
Every node keeps logs: its application log, and a log for each pipeline run, network and network instance. Use this service to follow a log live or to download a complete log file, from any node.
Open log stream
Stream the log messages of one log on a node. The requested number of past entries is sent first, then new entries as they are written. Fails with an invalid argument error when the node is invalid or no log is chosen, and ends with an error when the log cannot be read or the node loses its connection.
- REST
- gRPC
The body names the log to stream, for example {"appLogStreamRequest": {}} or {"pipelineRunLogStreamRequest": {"pipelineRunId": "..."}}.
/v1/streams/nodes/{node_id}/logsServer-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 whose log to stream.
optionsOptionsStream options. When unset, only new entries are sent.
appLogStreamRequestOpenAppLogStreamRequestone of requestStream the node's application log.
pipelineRunLogStreamRequestOpenPipelineRunLogStreamRequestone of requestStream the log of a pipeline run.
networkLogStreamRequestOpenNetworkLogStreamRequestone of requestStream the log of a network.
networkInstanceLogStreamRequestOpenNetworkInstanceLogStreamRequestone of requestStream the log of a network instance.
- 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.logging.openLogStream({
nodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
options: {
lines: "0"
},
appLogStreamRequest: {}
})) {
}
from nanoping_api import NanopingClient, OpenAppLogStreamRequest, Options
client = NanopingClient("http://127.0.0.1:10565")
for response in client.logging.open_log_stream(
node_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
options=Options(lines=0),
app_log_stream_request=OpenAppLogStreamRequest(),
):
print(response)
curl -N -X POST 'http://127.0.0.1:10565/v1/streams/nodes/<node_id>/logs' \
-H 'Content-Type: application/json' \
-d '{
"options": {
"lines": "0"
},
"appLogStreamRequest": {}
}'
messagesMessage[]The log entries.
rpc openLogStream(OpenLogStreamRequest) returns (stream Messages)
Method /nanopinggrpc.logging.LoggingService/openLogStream
node_idstringID of the node whose log to stream.
optionsOptionsStream options. When unset, only new entries are sent.
app_log_stream_requestOpenAppLogStreamRequestone of requestStream the node's application log.
pipeline_run_log_stream_requestOpenPipelineRunLogStreamRequestone of requestStream the log of a pipeline run.
network_log_stream_requestOpenNetworkLogStreamRequestone of requestStream the log of a network.
network_instance_log_stream_requestOpenNetworkInstanceLogStreamRequestone of requestStream the log of a network instance.
messagesMessage[]The log entries.
- Go
- Go (generated gRPC)
import (
client "github.com/nanoping-labs/nanoping-api-go/v11"
"github.com/nanoping-labs/nanoping-api-go/v11/logging"
)
c, err := client.Connect("127.0.0.1:10432")
defer c.Close()
stream, err := c.Logging.OpenLogStream(ctx, &logging.OpenLogStreamRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
Options: &logging.Options{
OptionalLines: &logging.Options_Lines{Lines: 0},
},
Request: &logging.OpenLogStreamRequest_AppLogStreamRequest{AppLogStreamRequest: &logging.OpenAppLogStreamRequest{}},
})
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/logging"
)
conn, err := grpc.NewClient("127.0.0.1:10432", grpc.WithTransportCredentials(insecure.NewCredentials()))
defer conn.Close()
stub := logging.NewLoggingServiceClient(conn)
stream, err := stub.OpenLogStream(ctx, &logging.OpenLogStreamRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
Options: &logging.Options{
OptionalLines: &logging.Options_Lines{Lines: 0},
},
Request: &logging.OpenLogStreamRequest_AppLogStreamRequest{AppLogStreamRequest: &logging.OpenAppLogStreamRequest{}},
})
for {
response, err := stream.Recv()
if err != nil {
return err
}
}
Download log file
Download one complete log file from a node as a series of chunks. Join the chunks in order to get the file. The stream ends when the whole file has been sent, or after an error chunk when the file could not be read.
- REST
- gRPC
The log file is returned as plain text. The query string names the log, for example pipelineRunLogFileRequest.pipelineRunId=..., and the app log is returned when it names none.
/v1/nodes/{node_id}/log-fileReturns the file as the response body.
node_idstringID of the node that holds the log file.
app_log_file_requestDownloadAppLogFileRequestone of requestDownload the node's application log.
pipeline_run_log_file_requestDownloadPipelineRunLogFileRequestone of requestDownload the log of a pipeline run.
network_log_file_requestDownloadNetworkLogFileRequestone of requestDownload the log of a network.
network_instance_log_file_requestDownloadNetworkInstanceLogFileRequestone of requestDownload the log of a network instance.
- TypeScript
- Python
- curl
import { NanopingClient } from "@nanoping/api";
const client = new NanopingClient({ baseUrl: "http://127.0.0.1:10565" });
const logFile = await client.logging.downloadLogFile({
nodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
appLogFileRequest: {}
});
from nanoping_api import DownloadAppLogFileRequest, NanopingClient
client = NanopingClient("http://127.0.0.1:10565")
log_file = client.logging.download_log_file(
node_id="3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
app_log_file_request=DownloadAppLogFileRequest(),
)
curl 'http://127.0.0.1:10565/v1/nodes/<node_id>/log-file'
rpc downloadLogFile(DownloadLogFileRequest) returns (stream DownloadLogFileChunk)
Method /nanopinggrpc.logging.LoggingService/downloadLogFile
node_idstringID of the node that holds the log file.
app_log_file_requestDownloadAppLogFileRequestone of requestDownload the node's application log.
pipeline_run_log_file_requestDownloadPipelineRunLogFileRequestone of requestDownload the log of a pipeline run.
network_log_file_requestDownloadNetworkLogFileRequestone of requestDownload the log of a network.
network_instance_log_file_requestDownloadNetworkInstanceLogFileRequestone of requestDownload the log of a network instance.
errorstringone of responseWhy the file could not be read, for example because it does not exist. No more chunks follow.
file_chunkLogFileChunkone of responseThe next piece of the file.
- Go
- Go (generated gRPC)
import (
client "github.com/nanoping-labs/nanoping-api-go/v11"
"github.com/nanoping-labs/nanoping-api-go/v11/logging"
)
c, err := client.Connect("127.0.0.1:10432")
defer c.Close()
stream, err := c.Logging.DownloadLogFile(ctx, &logging.DownloadLogFileRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
Request: &logging.DownloadLogFileRequest_AppLogFileRequest{AppLogFileRequest: &logging.DownloadAppLogFileRequest{}},
})
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/logging"
)
conn, err := grpc.NewClient("127.0.0.1:10432", grpc.WithTransportCredentials(insecure.NewCredentials()))
defer conn.Close()
stub := logging.NewLoggingServiceClient(conn)
stream, err := stub.DownloadLogFile(ctx, &logging.DownloadLogFileRequest{
NodeId: "3f2b1c9e-8d4a-4f6b-9c2e-1a7d5e8b0c4f",
Request: &logging.DownloadLogFileRequest_AppLogFileRequest{AppLogFileRequest: &logging.DownloadAppLogFileRequest{}},
})
for {
response, err := stream.Recv()
if err != nil {
return err
}
}