Protobuf Logging Reference¶
-
newRemoteLogger(
address[,timeout= 2[,maxQueuedEntries= 100[,reconnectWaitTime= 1[,connectionCount= 1]]]]
)¶ Changed in version 2.0.0: Added the optional
connectionCountparameter.Create a Remote Logger object, to use with
RemoteLogAction()andRemoteLogResponseAction().- Parameters:¶
address (
string) – An IP:PORT combination where the logger is listeningtimeout (
int) – TCP connect timeout in secondsmaxQueuedEntries (
int) – Queue this many messages before dropping new ones (e.g. when the remote listener closes the connection)reconnectWaitTime (
int) – Time in seconds between reconnection attemptsconnectionCount (
int) – Number of connections to open to the socket
- class DNSDistProtoBufMessage¶
This object represents a single protobuf message as emitted by dnsdist.
- addResponseRR(name, type, class, ttl, blob)¶
Add a response RR to the protobuf message.
- Parameters:¶
name (
string) – The RR name.type (
int) – The RR type.class (
int) – The RR class.ttl (
int) – The RR TTL.blob (
string) – The RR binary content.
- setEDNSSubnet(netmask)¶
Set the EDNS Subnet to
netmask.- Parameters:¶
netmask (
string) – The netmask to set to.
- setQueryTime(sec, usec)¶
In a response message, set the time at which the query has been received.
- Parameters:¶
sec (
int) – Unix timestamp when the query was received.usec (
int) – The microsecond the query was received.
- setQuestion(name, qtype, qclass)¶
Set the question in the protobuf message.
- setProtobufResponseType(sec, usec)¶
Change the protobuf response type from a query to a response, and optionally set the query time.
- Parameters:¶
sec (
int) – Optional query time in seconds.usec (
int) – Optional query time in additional micro-seconds.
-
setRequestor(
address[,port])¶ Set the requestor’s address.
- Parameters:¶
address (
ComboAddress) – The address to set toport (
int) – The requestor source port
-
setRequestorFromString(
address[,port])¶ Set the requestor’s address from a string.
- Parameters:¶
address (
string) – The address to set toport (
int) – The requestor source port
-
setResponder(
address[,port])¶ Set the responder’s address.
- Parameters:¶
address (
ComboAddress) – The address to set toport (
int) – The responder port
-
setResponderFromString(
address[,port])¶ Set the responder’s address.
- Parameters:¶
address (
string) – The address to set toport (
int) – The responder port
- setResponseCode(rcode)¶
Set the response code of the query.
- Parameters:¶
rcode (
int) – The response code of the answer
- setTime(sec, usec)¶
Set the time at which the query or response has been received.
- Parameters:¶
sec (
int) – Unix timestamp when the query was received.usec (
int) – The microsecond the query was received.
-
toDebugString():
string¶ Return a string containing the content of the message
Exporting tags¶
func:RemoteLogAction and RemoteLogResponseAction() can be configured to include internal tags in the protocol buffer messages that are exported, using the exportTags/export_tags options. The following example exports all internal tags using the special * value:
remote_logging:
protobuf_loggers:
- name: "pblog"
address: "127.0.0.1:5301"
query_rules:
- name: Export queries including internal tags
selector:
type: All
action:
type: RemoteLog
logger_name: "pblog"
export_tags: "*"
rl = newRemoteLogger('127.0.0.1:5301')
addAction(AllRule(), RemoteLogAction(rl, nil, {exportTags='*'}))
The exportTagsPrefixes/export_tags_prefixes options can also be used to export all tags whose keys start with a given prefix, and exportTagsStripPrefixes/export_tags_strip_prefixes to remove the specified prefix from the key before inserting into the message. The following example exports all internal tags starting with pdns- and removes the prefix from the key before adding them to the protocol buffer message:
remote_logging:
protobuf_loggers:
- name: "pblog"
address: "127.0.0.1:5301"
query_rules:
- name: Export queries including internal tags
selector:
type: All
action:
type: RemoteLog
logger_name: "pblog"
export_tags_prefixes:
- "pdns-"
export_tags_strip_prefixes: true
rl = newRemoteLogger('127.0.0.1:5301')
addAction(AllRule(), RemoteLogAction(rl, nil, {exportTagsPrefixes='pdns-', exportTagsStripPrefixes=true}))