Protobuf Logging Reference

newRemoteLogger(
    address[, timeout = 2[, maxQueuedEntries = 100[, reconnectWaitTime = 1[, connectionCount = 1, stalledWriteTimeout = 5]]]]
)

Changed in version 2.0.0: Added the optional connectionCount parameter.

Changed in version 2.2.0: Added the optional stalledWriteTimeout parameter.

Create a Remote Logger object, to use with RemoteLogAction() and RemoteLogResponseAction().

Parameters:
  • address (string) – An IP:PORT combination where the logger is listening

  • timeout (int) – TCP connect timeout in seconds

  • maxQueuedEntries (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 attempts

  • connectionCount (int) – Number of connections to open to the socket

  • stalledWriteTimeout (int) – If we have been unable to write or buffer data on our side of the TCP socket for that long, in seconds, consider that the remote endpoint has died and reconnect

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.

setBytes(bytes)

Set the size of the query

Parameters:

bytes (int) – Number of bytes in the query.

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.

Parameters:
  • name (DNSName) – The qname of the question

  • qtype (int) – The qtype of the question

  • qclass (int) – The qclass of the question

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 to

  • port (int) – The requestor source port

setRequestorFromString(address[, port])

Set the requestor’s address from a string.

Parameters:
  • address (string) – The address to set to

  • port (int) – The requestor source port

setResponder(address[, port])

Set the responder’s address.

Parameters:
  • address (ComboAddress) – The address to set to

  • port (int) – The responder port

setResponderFromString(address[, port])

Set the responder’s address.

Parameters:
  • address (string) – The address to set to

  • port (int) – The responder port

setResponseCode(rcode)

Set the response code of the query.

Parameters:

rcode (int) – The response code of the answer

setServerIdentity(id)

Set the server identify field.

Parameters:

id (string) – The server ID

setTag(value)

Add a tag to the list of tags.

Parameters:

value (string) – The tag value

setTagArray(valueList)

Add a list of tags.

Parameters:

tags (table) – A list of tags as strings

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}))