Skip to content

Fix TCP & UDP input metricsets for ports > 32767#46486

Merged
belimawr merged 2 commits intoelastic:mainfrom
belimawr:fix-tcp-udp-ports
Sep 10, 2025
Merged

Fix TCP & UDP input metricsets for ports > 32767#46486
belimawr merged 2 commits intoelastic:mainfrom
belimawr:fix-tcp-udp-ports

Conversation

@belimawr
Copy link
Copy Markdown
Contributor

@belimawr belimawr commented Sep 9, 2025

Proposed commit message

When parsing the port to collect metrics, the TCP & UDP inputs were
parsing the port as a int16, which limited the maximum port to
32767. This commit fixes it by parsing the port as uint16.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

## Disruptive User Impact
## Author's Checklist

How to test this PR locally

  1. Start Filebeat with the following configuration:

    filebeat.inputs:
      - type: udp
        host: 127.0.0.1:42000
    
    output.discard:
      enabled: true
    
    logging:
      to_stderr: true
      level: warning
    
    http.enabled: true
  2. Ensure the following waring is not in the logs:

    {
      "log.level": "warn",
      "@timestamp": "2025-09-09T18:02:06.893-0400",
      "log.logger": "input.udp",
      "log.origin": {
        "function": "github.com/elastic/beats/v7/filebeat/input/netmetrics.NewUDP",
        "file.name": "netmetrics/udp.go",
        "file.line": 65
      },
      "message": "failed to get port for 127.0.0.1:42000: strconv.ParseInt: parsing \"42000\": value out of range",
      "service.name": "filebeat",
      "id": "8C542040A200BF6D",
      "host": "127.0.0.1:42000",
      "ecs.version": "1.6.0"
    }
  3. Start sending some data in the UDP port

    docker run -it --rm mingrammer/flog -l | nc -vu localhost 42000 
    
  4. Get the input metrics from http://localhost:5066/inputs/ and ensure receive_queue_length is populated.

    curl http://localhost:5066/inputs/ -s|jq '.[].receive_queue_length'
    

    You might have to call curl multiple times, as the value some times is zero.

## Related issues
## Use cases
## Screenshots
## Logs

When parsing the port to collect metrics, the TCP & UDP inputs were
parsing the port as a int16, which limited the maximum port to
32767. This commit fixes it by parsing the port as uint16.
@belimawr belimawr self-assigned this Sep 9, 2025
@belimawr belimawr added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Sep 9, 2025
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Sep 9, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 9, 2025

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Sep 9, 2025

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @belimawr? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@belimawr belimawr marked this pull request as ready for review September 10, 2025 15:58
@belimawr belimawr requested a review from a team as a code owner September 10, 2025 15:58
@belimawr belimawr requested review from AndersonQ and rdner September 10, 2025 15:58
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@belimawr belimawr added the backport-active-all Automated backport with mergify to all the active branches label Sep 10, 2025
@belimawr belimawr merged commit 8ee7685 into elastic:main Sep 10, 2025
50 of 53 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

@Mergifyio backport 8.18 8.19 9.0 9.1

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Sep 10, 2025

backport 8.18 8.19 9.0 9.1

✅ Backports have been created

Details

mergify bot pushed a commit that referenced this pull request Sep 10, 2025
When parsing the port to collect metrics, the TCP & UDP inputs were
parsing the port as a int16, which limited the maximum port to
32767. This commit fixes it by parsing the port as uint16.

(cherry picked from commit 8ee7685)

# Conflicts:
#	filebeat/input/netmetrics/netmetrics_test.go
mergify bot pushed a commit that referenced this pull request Sep 10, 2025
When parsing the port to collect metrics, the TCP & UDP inputs were
parsing the port as a int16, which limited the maximum port to
32767. This commit fixes it by parsing the port as uint16.

(cherry picked from commit 8ee7685)
mergify bot pushed a commit that referenced this pull request Sep 10, 2025
When parsing the port to collect metrics, the TCP & UDP inputs were
parsing the port as a int16, which limited the maximum port to
32767. This commit fixes it by parsing the port as uint16.

(cherry picked from commit 8ee7685)

# Conflicts:
#	filebeat/input/netmetrics/netmetrics_test.go
mergify bot pushed a commit that referenced this pull request Sep 10, 2025
When parsing the port to collect metrics, the TCP & UDP inputs were
parsing the port as a int16, which limited the maximum port to
32767. This commit fixes it by parsing the port as uint16.

(cherry picked from commit 8ee7685)
shmsr pushed a commit that referenced this pull request Sep 11, 2025
When parsing the port to collect metrics, the TCP & UDP inputs were
parsing the port as a int16, which limited the maximum port to
32767. This commit fixes it by parsing the port as uint16.
pierrehilbert pushed a commit that referenced this pull request Sep 12, 2025
…67 (#46524)

* Fix TCP & UDP input metricsets for ports > 32767 (#46486)

When parsing the port to collect metrics, the TCP & UDP inputs were
parsing the port as a int16, which limited the maximum port to
32767. This commit fixes it by parsing the port as uint16.

(cherry picked from commit 8ee7685)

# Conflicts:
#	filebeat/input/netmetrics/netmetrics_test.go

* Fix merge conflicts

---------

Co-authored-by: Tiago Queiroz <tiago.queiroz@elastic.co>
pierrehilbert pushed a commit that referenced this pull request Sep 12, 2025
When parsing the port to collect metrics, the TCP & UDP inputs were
parsing the port as a int16, which limited the maximum port to
32767. This commit fixes it by parsing the port as uint16.

(cherry picked from commit 8ee7685)

Co-authored-by: Tiago Queiroz <tiago.queiroz@elastic.co>
pierrehilbert pushed a commit that referenced this pull request Sep 12, 2025
…767 (#46523)

* Fix TCP & UDP input metricsets for ports > 32767 (#46486)

When parsing the port to collect metrics, the TCP & UDP inputs were
parsing the port as a int16, which limited the maximum port to
32767. This commit fixes it by parsing the port as uint16.

(cherry picked from commit 8ee7685)

* Fix merge conflicts

---------

Co-authored-by: Tiago Queiroz <tiago.queiroz@elastic.co>
pierrehilbert pushed a commit that referenced this pull request Sep 12, 2025
…767 (#46522)

* Fix TCP & UDP input metricsets for ports > 32767 (#46486)

When parsing the port to collect metrics, the TCP & UDP inputs were
parsing the port as a int16, which limited the maximum port to
32767. This commit fixes it by parsing the port as uint16.

(cherry picked from commit 8ee7685)

# Conflicts:
#	filebeat/input/netmetrics/netmetrics_test.go

* Fix merge conflicts

---------

Co-authored-by: Tiago Queiroz <tiago.queiroz@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-all Automated backport with mergify to all the active branches Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants