Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[inputs.socket_listener] Metric size limit received via udp/unixgram #16118

Closed
MarekZydor opened this issue Oct 31, 2024 · 0 comments · Fixed by #16156
Closed

[inputs.socket_listener] Metric size limit received via udp/unixgram #16118

MarekZydor opened this issue Oct 31, 2024 · 0 comments · Fixed by #16156
Labels
bug unexpected problem or unintended behavior

Comments

@MarekZydor
Copy link
Contributor

MarekZydor commented Oct 31, 2024

Relevant telegraf.conf

[agent]
  interval = "10s"
  round_interval = true
  debug = true
  logfile = ""
  omit_hostname = true

[[inputs.socket_listener]]
  service_address = "unixgram:///tmp/telegraf.sock"
  data_format = "influx"
  read_buffer_size = "1000KiB"

Logs from Telegraf

...
Listening on unixgram:///tmp/telegraf.sock
2024-10-31T19:07:29Z E! [inputs.socket_listener] Error in plugin: metric parse error: expected field at 1:65537: "...jgpmyresaklorgpfpdoxykvjekusoocpqxtkglzdvvpcsecdadczaalwteszvamddpnduxwfhqpfypnjyvyrlosfkyqobxpfgbgdagsrhltcdtbhjqoppuyfrvkykpmpwfkmfmdrcmhzrvxtozkicvabxuhjbkmjizvslmqipevsciypzgqvyncckcynnlgkdoiomsxrnltricgdlgmfvysmrfrwiribzpjtqqtqqgiripuwnvbpphoeeaxbranwcgoimlpgszvjcedizoqazxxenipuuhkrclvmpvbcypanzufehfwsohgewxmisljrzudsalhfqsjxbtqptxhmpwvfwikilkiuhjdmcpzaadumxouddflvrzbzjuycgwbszwcccpiqiaaeptvuihmgykqyuqlkmvxbutlfutvwsztsvttqnzcevkrpgwqkfyuhdkiccjeutyzpsefbghfgyweouorqscyiqmvsqlnlgwtipdqvistfkcoyvqvueoqdynnwexjcyzpratciomuygookkdkyyfhdbxmwbilebesigwlujefzpxxfkjzyqhnilmkskpttnptetmopxwkyotsfwhwzumthyohgxbuwmebpcolatistygxkwotoeyfpurorafmbqpizrxqixgfygyuxcuqhbjpunqcmfqtjrdgjqbtllxgfgapbwihnkkdipipvviyivgtiocgiypfjdtqqvxoznfjkhkndcnpemrqwdtosarliutaovtnjvkttgfqgiwaumctxynstjqumhjnpnokgjjpuvfoctxychfflpywpdjmuxwfjmpucvpeunalshwoavgjrkokeatzxssyefdeykbahritdiazmjcbeoqrpgqqjzuwrkrjgcpxftnlyfbjwtyzhpvocjvvcryntoaeiqonmkzpphqdnqasurthtgiceclcxlvvqdbqjiafehueezeypdlpfziadwcpvcffwfvrahouesdfdpspfroprctfwomidaaadglwm<-- here"

System info

telegraf 1.32.1, ubuntu 22.04

Docker

No response

Steps to reproduce

Send a metric longer than 65537 bytes over unixgram (a Unix domain socket with SOCK_DGRAM type) or UDP. I could understand this error if only UDP was used (since the packet size limit is 65537 bytes), but that limit doesn’t apply to unixgram (where the only size limits are the write buffer settings: net.core.wmem_default, net.core.wmem_max).

You can use this C++ app to send it:
(also increase write buffer size if necessary)

#include <iostream>
#include <cstring>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>

int main() {
    const char* socket_path = "/tmp/telegraf.sock";
    const char* message = R"(cpu,host=server1,region=us-west usage_idle="LONG STRING OVER 64KiB")";

    // Create a UDS datagram socket
    int sockfd = socket(AF_UNIX, SOCK_DGRAM, 0);
    if (sockfd == -1) {
        perror("Socket creation failed");
        return EXIT_FAILURE;
    }

    // Define the server address
    struct sockaddr_un server_addr;
    std::memset(&server_addr, 0, sizeof(server_addr));
    server_addr.sun_family = AF_UNIX;
    std::strncpy(server_addr.sun_path, socket_path, sizeof(server_addr.sun_path) - 1);

    // Send the message using sendto
    ssize_t bytes_sent = sendto(sockfd, message, std::strlen(message), 0,
                                (struct sockaddr*)&server_addr, sizeof(server_addr));
    if (bytes_sent == -1) {
        perror("Send failed");
        close(sockfd);
        return EXIT_FAILURE;
    }

    std::cout << "Sent message: " << message << std::endl;

    // Close the socket
    close(sockfd);

    return EXIT_SUCCESS;
}

Expected behavior

The entire metric is read.

Actual behavior

Telegraf can't find the end of the string field.

Additional info

This is a continuation of issue #16082, in which it was fixed the metric limit sent over TCP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
1 participant