home/docs/help/dns_sd.md
HertzBeat integrates with DNS service to automatically discover service instances through DNS records and create monitoring tasks for them.
DNS Service Discovery allows HertzBeat to discover service instances by querying DNS records. This is a simple and reliable service discovery method that utilizes standard DNS infrastructure to find service instances. It is particularly suitable for environments using DNS SRV records or environments that need to discover services through DNS.
Ensure your DNS server has properly configured service discovery records. Different record types have different formats:
| Parameter name | Parameter help description |
|---|---|
| Target Name | Identify the name of this monitoring. The name needs to be unique. |
| DNS Host | DNS server address. Example: 8.8.8.8 or 192.168.1.1 |
| DNS Port | DNS server port. The default is 53 |
| Record Type | Type of DNS record to query. Options: SRV, A, AAAA, MX, NS |
| Record Name | Name of the DNS record to query. Example: _http._tcp.example.com for SRV records |
| Collection interval | Interval time of monitor periodic data collection, unit: second, and the minimum interval that can be set is 30 seconds. |
| Description remarks | For more information about identifying and describing this monitoring, users can note information here. |
Create Service Discovery Monitoring
Configure Monitoring Template
Automatic Discovery
View Discovered Instances
Suppose you have an SRV record for your web service:
_http._tcp.example.com8.8.8.8Configuration example:
DNS-SRV-Discovery8.8.8.853SRV_http._tcp.example.com60 secondsPort monitoring (using the port from SRV record)After configuration:
_http._tcp.example.comDiscover service instances through A records:
services.example.comConfiguration example:
192.168.1.1 (Internal DNS server)53Aservices.example.comPing or Port monitoringDiscover mail servers through MX records:
8.8.8.8MXexample.comPort monitoring (port 25)SRV records are the most commonly used record type for service discovery, containing service name, port number, and priority information.
Format: _service._protocol.example.com
Example: _http._tcp.example.com
Typical SRV record response contains:
A records map domain names to IPv4 addresses. If a domain name resolves to multiple IPs, all IPs can be discovered.
Example: services.example.com → 192.168.1.10, 192.168.1.11, 192.168.1.12
AAAA records map domain names to IPv6 addresses.
Example: services.example.com → 2001:db8::1
MX records specify mail servers for a domain and include priority information.
Example: example.com → mail.example.com
NS records specify name servers for a domain.
Example: example.com → ns1.example.com
| Metric name | Metric unit | Metric help description |
|---|---|---|
| target | none | Discovered service instance target |
| host | none | Service instance host address |
| port | none | Service instance port number |
Different services use different SRV record formats:
_http._tcp.example.com_https._tcp.example.com_ldap._tcp.example.com_ftp._tcp.example.com_mysql._tcp.example.com_postgresql._tcp.example.comIn Kubernetes clusters, DNS service discovery can be used to discover pod instances:
Example:
10.96.0.10)Amy-service.default.svc.cluster.localPort monitoringCommonly used DNS servers:
8.8.8.8, 8.8.4.41.1.1.1, 1.0.0.19.9.9.9208.67.222.222, 208.67.220.220