Search all InfluxData sources [inputs.gnmi] Error in plugin: failed to setup subscription: rpc error: code = Unavailable

Faced the same challenge.

We have created tls certificate and added the same in conf file. It worked.

Hello @DeepikaSivalingam,
Can you please share your telegraf config?

Hi anaisdg,

Im facing same issue could you please help me?

Telegraf. Conf

[[inputs.gnmi]]

addresses [“199.100.11.1:57400”]

username “admin”

password “admin”

encoding “json ietf”

insecure_skip verify true

redial “605”

[[inputs.gomi.subscription]]

name “hostname”

origin “openconfig”

path=“/system/name/host-name”

subscription mode “sample”

sample interval “605”

[[outputs.influxdb]]

urls[“http://localhost:8428”]

database “telegraf”

retention policy -

write_consistency = “any”

timeout=“605”

[agent]

interval “105”

round interval = true

metric_batch_size - 1000

metric buffer limit = 10000

collection jitter = “0s”

flush interval - “105”

flush jitter= “05”

precision=" "

debug= true

logtarget =“file”

logfile = “/var/log/telegraf/telegraf.log”

logfile rotation max size = “10MB”

logfile rotation max archives = 5

quiet = false

logfile_rotation_max_size = “10MB”

logfile_rotation_max_archives = 5

error:

Apr 28 10:17:46 10.177.166.241 telegraf [2922611]: 2025-04-28T10:17:46Z E! [inputs.gnmi] Error in plugin: failed to setup subscription: rpc error:
connection closed before server preface received

Hello @theja,
I’m not sure.

Can you try the following trouble shooting ideas?

The plugin documentation mentions that tls handshake failures can occur due to insecure tls configurations in the GNMI server. Maybe adjust tls_min_version or tls_cipher_suites telegraf/plugins/inputs/gnmi/README.md at master · influxdata/telegraf · GitHub.

Use debug = true to check logs and share them.

This could help too? Or this user might?

Otherwise @skartikey might know something I don’t :slight_smile:

Hello @annaidg ,

Im using Telegraf 1.21.4+dsl-0ubuntu2 version cannot able to use the tls_min and tls_cipher

The logs for current version is

25-04-29T07:20:392 E! [inputs.gnmi] Error in plugin: failed to setup subscription: rpc error: code Unavailable desc connection closed before server preface temelved

25-04-29T07:20:492 D! [outputs.influxdb] Buffer fullness: 0/10000 metrics

25-04-29T07:20:592 D! [outputs.influxdb] Buffer fullness: 0/10000 metrica

25-04-29T07:21:09Z D! [outputs.influxdb) Buffer fullness: 0/10000 metrica

25-04-29T07:21:192 D! [outputs.influxdb] Buffer fullness: 0/10000 metrics

[C^[[C^[[C^ [[C2025-04-29T07:21:29Z D! [outputs.influxdb] Buffer fullness: 0/10000 metrics

25-04-29T07:21:392 D! [outputs.influxdb] Buffer fullness: 0/10000 metrics

25-04-29T07:21:492 D! [outputs.influxdb] Buffer fullness: 0/10000 metrics

25-04-29T07:21:59Z D! [outputs.influxdb] Buffer fullness: 0/10000 metrics

25-04-29T07:22:09Z D! [outputs.influxdb] Buffer fullness: 0/10000 metrics

25-04-29T07:22:19Z D! [outputs.influxdb] Buffer fullness: 0/10000 metrics

25-04-29T07:22:19Z E! [inputs.gnmi] Error in plugin: failed to setup subscription: rpc error: code Unavailable desc connection closed before server preface received

Could u please help???

@skartikey could u please help me on this???

@oldguardmd1 ?? U have any idea on this??

@DeepikaSivalingam and @theja Welcome to influxdata community!

I see you’re facing a gNMI connection error: “failed to setup subscription: rpc error: code Unavailable desc = connection closed before server preface received”

This error typically occurs when there’s a connection issue between Telegraf and the gNMI server. Here are several things to check and try:

  1. Check Network Connectivity:
# Test if you can reach the gNMI server
telnet 199.100.11.1 57400
# Or use nc
nc -v 199.100.11.1 57400
  1. Check TLS Configuration:
    Since you’re using insecure_skip_verify = true, make sure you’ve added an underscore between the words:
[[inputs.gnmi]]
  addresses = ["199.100.11.1:57400"]
  username = "admin"
  password = "admin"
  encoding = "json_ietf"
  insecure_skip_verify = true
  redial = "605"
  1. Fix Configuration Syntax:
    Your configuration has several syntax issues. Here’s a corrected version:
[[inputs.gnmi]]
  addresses = ["199.100.11.1:57400"]
  username = "admin"
  password = "admin"
  encoding = "json_ietf"
  insecure_skip_verify = true
  redial = "60s"
  
  [[inputs.gnmi.subscription]]
    name = "hostname"
    origin = "openconfig"
    path = "/system/state/hostname"
    subscription_mode = "sample"
    sample_interval = "60s"

[[outputs.influxdb]]
  urls = ["http://localhost:8428"]
  database = "telegraf"
  timeout = "60s"

[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = ""
  debug = true
  logtarget = "file"
  logfile = "/var/log/telegraf/telegraf.log"
  logfile_rotation_max_size = "10MB"
  logfile_rotation_max_archives = 5
  quiet = false
  1. For TLS Configuration (since you can’t use tls_min and tls_cipher):
    Try adding these settings in your gNMI input:
[[inputs.gnmi]]
  # ... existing configuration ...
  
  # Try adding these for TLS compatibility
  tls_ca = "/path/to/ca.crt"  # If you have a CA certificate
  tls_cert = "/path/to/client.crt"  # If you need client certificate
  tls_key = "/path/to/client.key"   # If you need client key
  1. Port and Protocol Check:
  • Ensure port 57400 is open on the gNMI server
  • Verify the server is listening on this port
  • Check if the server expects HTTP or HTTPS
  1. Debug Steps:
# Enable debug mode to see more detailed logs
journalctl -u telegraf -f

# Test connectivity with openssl
openssl s_client -connect 199.100.11.1:57400 -showcerts

# Check Telegraf version
telegraf --version
  1. Alternative Configuration:
    If the above doesn’t work, try this minimal configuration:
[[inputs.gnmi]]
  addresses = ["199.100.11.1:57400"]
  username = "admin"  
  password = "admin"
  insecure_skip_verify = true
  redial = "60s"
  
  [[inputs.gnmi.subscription]]
    path = "/system/state/hostname"
    mode = "sample"
    interval = "60s"

If none of these solutions work, could you provide:

  1. The exact model of the network device you’re connecting to?
  2. Any firewall logs that might show blocked connections?
  3. Output of telegraf --test --config /path/to/your/config?

This will help me provide more specific guidance for your situation.