This is an automated email from the ASF dual-hosted git repository.
gongchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git
The following commit(s) were added to refs/heads/master by this push:
new d8f844427 [feature] dns add record type (#3799)
d8f844427 is described below
commit d8f8444275fd2deb9f56d801b21ada372aa93cc2
Author: pentium100 <[email protected]>
AuthorDate: Sun Oct 5 08:58:34 2025 +0800
[feature] dns add record type (#3799)
Co-authored-by: Tomsun28 <[email protected]>
---
.../collector/collect/dns/DnsCollectImpl.java | 2 +-
.../collector/collect/dns/DnsCollectImplTest.java | 1 +
.../common/entity/job/protocol/DnsProtocol.java | 3 +-
.../src/main/resources/define/app-dns.yml | 34 ++++++++++++++++++++++
home/docs/help/dns.md | 1 +
5 files changed, 39 insertions(+), 2 deletions(-)
diff --git
a/hertzbeat-collector/hertzbeat-collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/dns/DnsCollectImpl.java
b/hertzbeat-collector/hertzbeat-collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/dns/DnsCollectImpl.java
index 8b67250f4..9c5d897d2 100644
---
a/hertzbeat-collector/hertzbeat-collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/dns/DnsCollectImpl.java
+++
b/hertzbeat-collector/hertzbeat-collector-basic/src/main/java/org/apache/hertzbeat/collector/collect/dns/DnsCollectImpl.java
@@ -158,7 +158,7 @@ public class DnsCollectImpl extends AbstractCollect {
responseTimeStopWatch.start();
Name name = Name.fromString(dns.getAddress(), Name.root);
- Message query = Message.newQuery(Record.newRecord(name, Type.ANY,
DClass.value(dns.getQueryClass())));
+ Message query = Message.newQuery(Record.newRecord(name,
Type.value(dns.getRecordType()), DClass.value(dns.getQueryClass())));
Resolver res = new SimpleResolver(dns.getDnsServerIP());
res.setTimeout(Duration.of(Long.parseLong(dns.getTimeout()),
ChronoUnit.MILLIS));
res.setTCP(Boolean.parseBoolean(dns.getTcp()));
diff --git
a/hertzbeat-collector/hertzbeat-collector-basic/src/test/java/org/apache/hertzbeat/collector/collect/dns/DnsCollectImplTest.java
b/hertzbeat-collector/hertzbeat-collector-basic/src/test/java/org/apache/hertzbeat/collector/collect/dns/DnsCollectImplTest.java
index bdb5621fd..cbdd48582 100644
---
a/hertzbeat-collector/hertzbeat-collector-basic/src/test/java/org/apache/hertzbeat/collector/collect/dns/DnsCollectImplTest.java
+++
b/hertzbeat-collector/hertzbeat-collector-basic/src/test/java/org/apache/hertzbeat/collector/collect/dns/DnsCollectImplTest.java
@@ -46,6 +46,7 @@ public class DnsCollectImplTest {
.queryClass("IN")
.address("www.google.com")
.timeout("3000")
+ .recordType("A")
.port("53")
.tcp("tcp")
.build();
diff --git
a/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/DnsProtocol.java
b/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/DnsProtocol.java
index 62dd0e024..9982d25da 100644
---
a/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/DnsProtocol.java
+++
b/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/DnsProtocol.java
@@ -37,9 +37,10 @@ public class DnsProtocol implements CommonRequestProtocol,
Protocol {
private String timeout;
private String tcp;
private String queryClass;
+ private String recordType;
public boolean isInvalid() {
- return StringUtils.isAnyBlank(dnsServerIP, port, address, timeout,
tcp, queryClass);
+ return StringUtils.isAnyBlank(dnsServerIP, port, address, timeout,
tcp, queryClass, recordType);
}
@Override
diff --git a/hertzbeat-manager/src/main/resources/define/app-dns.yml
b/hertzbeat-manager/src/main/resources/define/app-dns.yml
index b47bc084b..9277c11e4 100644
--- a/hertzbeat-manager/src/main/resources/define/app-dns.yml
+++ b/hertzbeat-manager/src/main/resources/define/app-dns.yml
@@ -94,6 +94,30 @@ params:
# default value false
# 默认值 false
defaultValue: false
+ - field: recordType
+ # name-param field display i18n name
+ name:
+ zh-CN: 记录类型
+ en-US: Record Type
+ ja-JP: レコードタイプ
+ # type-param field type(radio mapping the html radio tag)
+ type: radio
+ # required-true or false
+ required: true
+ # when type is radio checkbox, use option to show optional values
{name1:value1,name2:value2}
+ options:
+ - label: SRV
+ value: SRV
+ - label: A
+ value: A
+ - label: AAAA
+ value: AAAA
+ - label: MX
+ value: MX
+ - label: NS
+ value: NS
+ - label: ANY
+ value: ANY
- field: queryClass
# name-param field display i18n name
name:
@@ -194,6 +218,8 @@ metrics:
tcp: ^_^tcp^_^
# Query Class
queryClass: ^_^queryClass^_^
+ # Record Type
+ recordType: ^_^recordType^_^
# metrics - question
- name: question
@@ -228,6 +254,8 @@ metrics:
tcp: ^_^tcp^_^
# Query Class
queryClass: ^_^queryClass^_^
+ # Record Type
+ recordType: ^_^recordType^_^
# metrics - answer
- name: answer
@@ -316,6 +344,8 @@ metrics:
tcp: ^_^tcp^_^
# Query Class
queryClass: ^_^queryClass^_^
+ # Record Type
+ recordType: ^_^recordType^_^
# metrics - authority
- name: authority
@@ -404,6 +434,8 @@ metrics:
tcp: ^_^tcp^_^
# Query Class
queryClass: ^_^queryClass^_^
+ # Record Type
+ recordType: ^_^recordType^_^
# metrics - additional
- name: additional
@@ -492,3 +524,5 @@ metrics:
tcp: ^_^tcp^_^
# Query Class
queryClass: ^_^queryClass^_^
+ # Record Type
+ recordType: ^_^recordType^_^
diff --git a/home/docs/help/dns.md b/home/docs/help/dns.md
index 3d6a5fe4b..f68fba922 100644
--- a/home/docs/help/dns.md
+++ b/home/docs/help/dns.md
@@ -18,6 +18,7 @@ keywords: [ open source monitoring tool, open source DNS
monitoring tool, monito
| Monitoring port | The port for DNS service provided to the
outside,default is 53.
|
| Address For DNS | The address for domain name resolution.
|
| Connect Timeout | Set the timeout for connecting to the DNS server,
default is 6000 milliseconds. |
+| Record Type | The type of DNS record to query. Optional values
include `A`, `AAAA`, `MX`, `NS`, `SRV`, and `ANY`. |
| Query Class | Resource class for DNS query. Optional values include
`IN`, `CHAOS`, `HESIOD`, `NONE`, and `ANY`,default is IN. |
| Use TCP Protocol | DNS queries use the TCP protocol.
|
| Collection interval | Interval time of monitor periodic data collection,
unit: second, and the minimum interval that can be set is 30 seconds. |
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]