diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d3c6235e0..82bf8114a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,8 @@ Main (unreleased) - Allow override debug metrics level for `otelcol.*` components. (@hainenber) +- Added support for NS records to `discovery.dns`. (@djcode) + ### Bugfixes - Fix panic when component ID contains `/` in `otelcomponent.MustNewType(ID)`.(@qclaogui) diff --git a/docs/sources/reference/components/discovery.dns.md b/docs/sources/reference/components/discovery.dns.md index ea7b766c98..ff3b6783da 100644 --- a/docs/sources/reference/components/discovery.dns.md +++ b/docs/sources/reference/components/discovery.dns.md @@ -20,12 +20,12 @@ discovery.dns "LABEL" { The following arguments are supported: -Name | Type | Description | Default | Required --------------------|----------------|------------------------------------------------------------------|---------|--------- -`names` | `list(string)` | DNS names to look up. | | yes -`port` | `number` | Port to use for collecting metrics. Not used for SRV records. | `0` | no -`refresh_interval` | `duration` | How often to query DNS for updates. | `"30s"` | no -`type` | `string` | Type of DNS record to query. Must be one of SRV, A, AAAA, or MX. | `"SRV"` | no +Name | Type | Description | Default | Required +-------------------|----------------|----------------------------------------------------------------------|---------|--------- +`names` | `list(string)` | DNS names to look up. | | yes +`port` | `number` | Port to use for collecting metrics. Not used for SRV records. | `0` | no +`refresh_interval` | `duration` | How often to query DNS for updates. | `"30s"` | no +`type` | `string` | Type of DNS record to query. Must be one of SRV, A, AAAA, MX, or NS. | `"SRV"` | no ## Exported fields @@ -41,7 +41,7 @@ Each target includes the following labels: * `__meta_dns_srv_record_target`: Target field of the SRV record. * `__meta_dns_srv_record_port`: Port field of the SRV record. * `__meta_dns_mx_record_target`: Target field of the MX record. - +* `__meta_dns_ns_record_target`: Target field of the NS record. ## Component health diff --git a/internal/component/discovery/dns/dns.go b/internal/component/discovery/dns/dns.go index 1f1be5a343..66832290e2 100644 --- a/internal/component/discovery/dns/dns.go +++ b/internal/component/discovery/dns/dns.go @@ -49,7 +49,7 @@ func (args *Arguments) SetToDefault() { func (args *Arguments) Validate() error { switch strings.ToUpper(args.Type) { case "SRV": - case "A", "AAAA", "MX": + case "A", "AAAA", "MX", "NS": if args.Port == 0 { return errors.New("a port is required in DNS-SD configs for all record types except SRV") }