Skip to content

Commit e735f11

Browse files
maxvpmaheshwarip
authored andcommitted
[Gateway] Logpush Resource Record fields (#17184)
1 parent 9101a5c commit e735f11

File tree

1 file changed

+18
-51
lines changed
  • src/content/docs/cloudflare-one/insights/logs

1 file changed

+18
-51
lines changed

src/content/docs/cloudflare-one/insights/logs/logpush.mdx

Lines changed: 18 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -48,63 +48,30 @@ Refer to the Logpush documentation for a list of available fields.
4848
| [Device Posture](/logs/reference/log-fields/account/device_posture_results/) | Device posture status from the WARP client |
4949
| [Session Logs](/logs/reference/log-fields/account/zero_trust_network_sessions/) | Network session logs for traffic proxied by Cloudflare Gateway |
5050

51-
## Parse Logpush logs
51+
## Parse DNS logs
5252

53-
Cloudflare Gateway logs DNS query information in [resource record format](https://datatracker.ietf.org/doc/html/rfc1035#section-4.1.3), a Base64-encoded binary format. The following resource record fields are available for each query:
53+
Logpush logs the following fields for each DNS query:
5454

5555
- Query name
5656
- Query type
5757
- Query class
5858
- Response TTL
5959
- Response data
6060

61-
To parse resource record logs from Logpush, run the following Python script with your desired samples:
62-
63-
```python
64-
import dnslib
65-
import base64
66-
67-
68-
# The samples from your Logpush output
69-
samples = [
70-
{"type":"1","data":"BnJlZGRpdANjb20AAAEAAQAAALwABJdlwYw="},
71-
{"type":"5","data":"BnNlY3VyZQV3bHhycwNjb20AAAUAAQAADggAIgZzZWN1cmUEYmFzZQV3bHhycwNjb20GYWthZG5zA25ldAA="},
72-
{"type":"28","data":"Bmdvb2dsZQNjb20AABwAAQAAAGkAECYH+LBAIxAJAAAAAAAAAGU="}]
73-
74-
75-
# Parse the Logpush RData.data field into Resource Records
76-
# See section "4.1.3. Resource record format" of https://www.ietf.org/rfc/rfc1035.txt
77-
# Includes Query Name, Query Type, Query Class, Response TTL, Response Data
78-
for sample in samples:
79-
decoded = base64.b64decode(sample["data"])
80-
buffer = dnslib.DNSBuffer(decoded)
81-
r = dnslib.RR.parse(buffer)
82-
print("== Print the full Resource Record ==")
83-
print(r)
84-
print("== Print individual components of the Resource Record ==")
85-
query_name = r.rname
86-
query_type = r.rtype
87-
query_class = r.rclass
88-
response_ttl = r.ttl
89-
response_data = r.rdata
90-
print(f"query name: {query_name} | query type: {query_type} | query class: {query_class} | ttl: {response_ttl} | rdata: {response_data}\n")
91-
```
92-
93-
The script will print a list of your samples. For example:
94-
95-
```txt
96-
== Print the full Resource Record ==
97-
reddit.com. 188 IN A 151.101.193.140
98-
== Print individual components of the Resource Record ==
99-
query name: reddit.com. | query type: 1 | query class: 1 | ttl: 188 | rdata: 151.101.193.140
100-
101-
== Print the full Resource Record ==
102-
secure.wlxrs.com. 3592 IN CNAME secure.base.wlxrs.com.akadns.net.
103-
== Print individual components of the Resource Record ==
104-
query name: secure.wlxrs.com. | query type: 5 | query class: 1 | ttl: 3592 | rdata: secure.base.wlxrs.com.akadns.net.
105-
106-
== Print the full Resource Record ==
107-
google.com. 105 IN AAAA 2607:f8b0:4023:1009::65
108-
== Print individual components of the Resource Record ==
109-
query name: google.com. | query type: 28 | query class: 1 | ttl: 105 | rdata: 2607:f8b0:4023:1009::65
61+
DNS query resource records are available in [Base64-encoded binary format](https://datatracker.ietf.org/doc/html/rfc1035#section-4.1.3) and JSON. For example:
62+
63+
```json
64+
{
65+
"ResourceRecords": [
66+
{
67+
"type": "5",
68+
"data": "d3d3LmV4YW1wbGUuY29tAAABAAUAAABleGFtcGxlLmNvbQ=="
69+
},
70+
{
71+
"type": "1",
72+
"data": "ZXhhbXBsZS5jb20AAAEAAQAAAQIDBAUGBwgJ"
73+
}
74+
],
75+
"ResourceRecordsJSON": "[{\"name\":\"www.example.com\",\"type\":\"CNAME\",\"class\":\"IN\",\"ttl\":300,\"rdata\":\"example.com.\"},{\"name\":\"example.com\",\"type\":\"A\",\"class\":\"IN\",\"ttl\":300,\"rdata\":\"203.0.113.0\"}]"
76+
}
11077
```

0 commit comments

Comments
 (0)