Skip to content

Commit

Permalink
Add dns.type to Packetbeat (elastic#13427)
Browse files Browse the repository at this point in the history
Set `dns.type` to `answer` when a response packet is present and to `query` when there's only a request packet.

Relates elastic#13320
  • Loading branch information
andrewkroh authored Aug 30, 2019
1 parent 3c7a26a commit ba71859
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packetbeat/protos/dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ func (dns *dnsPlugin) publishTransaction(t *dnsTransaction) {
pbf.Event.Start = t.request.ts
pbf.Event.End = t.response.ts

dnsEvent["type"] = "answer"
fields["method"] = dnsOpCodeToString(t.request.data.Opcode)
if len(t.request.data.Question) > 0 {
fields["query"] = dnsQuestionToString(t.request.data.Question[0])
Expand All @@ -407,6 +408,7 @@ func (dns *dnsPlugin) publishTransaction(t *dnsTransaction) {
pbf.Source.Bytes = int64(t.request.length)
pbf.Event.Start = t.request.ts

dnsEvent["type"] = "query"
fields["method"] = dnsOpCodeToString(t.request.data.Opcode)
if len(t.request.data.Question) > 0 {
fields["query"] = dnsQuestionToString(t.request.data.Question[0])
Expand All @@ -422,6 +424,7 @@ func (dns *dnsPlugin) publishTransaction(t *dnsTransaction) {
pbf.Destination.Bytes = int64(t.response.length)
pbf.Event.End = t.response.ts

dnsEvent["type"] = "answer"
fields["method"] = dnsOpCodeToString(t.response.data.Opcode)
if len(t.response.data.Question) > 0 {
fields["query"] = dnsQuestionToString(t.response.data.Question[0])
Expand Down

0 comments on commit ba71859

Please sign in to comment.