Metricbeat won't connect to Logstash over network

Hello all,

I have set up a full installation of the elastic stack (full for me, filebeat-logstash-elasticsearch-kibana) on ubuntu 18.04, and it was working perfectly but I need metricbeat to send logs from a local windows server. I installed metricbeat using these instructions, and when I got to needing to upload the index template:

.\metricbeat.exe setup --template -E output.logstash.enabled=false -E output.elasticsearch.hosts=["localhost:9200"]'

PS gave me this error complaining about how the request timed out. I adjusted the firewall and I got this error (hostname and ip redacted obviously):

Exiting: Couldn't connect to any of the configured Elasticsearch hosts. Errors:
[Error connection to Elasticsearch http://host:9200: Get http://host:9200: dial tcp ---.---.---.---:9200: connectex: No connection could be made because the target machine actively refused it.]

This is the metricbeat config (truncated for topic length):

###################### Metricbeat Configuration Example #######################

# This file is an example configuration file highlighting only the most common
# options. The metricbeat.reference.yml file from the same directory contains all the
# supported options with more comments. You can use it as a reference.
#
# You can find the full configuration reference here:
# https://www.elastic.co/guide/en/beats/metricbeat/index.html

#==========================  Modules configuration ============================

metricbeat.config.modules:
  # Glob pattern for configuration loading
  path: ${path.config}/modules.d/*.yml

  # Set to true to enable config reloading
  reload.enabled: false

  # Period on which files under path should be checked for changes
  #reload.period: 10s

#==================== Elasticsearch template setting ==========================

setup.template.settings:
  index.number_of_shards: 1
  index.codec: best_compression
  #_source.enabled: false

#================================ General =====================================

# The name of the shipper that publishes the network data. It can be used to group
# all the transactions sent by a single shipper in the web interface.
#name:

# The tags of the shipper are included in their own field with each
# transaction published.
#tags: ["service-X", "web-tier"]

# Optional fields that you can specify to add additional information to the
# output.
#fields:
#  env: staging


#============================== Dashboards =====================================
# These settings control loading the sample dashboards to the Kibana index. Loading
# the dashboards is disabled by default and can be enabled either by setting the
# options here or by using the `setup` command.
#setup.dashboards.enabled: false

# The URL from where to download the dashboards archive. By default this URL
# has a value which is computed based on the Beat name and version. For released
# versions, this URL points to the dashboard archive on the artifacts.elastic.co
# website.
#setup.dashboards.url:

#============================== Kibana =====================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
  # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
  #host: "localhost:5601"

  # Kibana Space ID
  # ID of the Kibana Space into which the dashboards should be loaded. By default,
  # the Default Space will be used.
  #space.id:

#============================= Elastic Cloud ==================================

# These settings simplify using metricbeat with the Elastic Cloud (https://cloud.elastic.co/).

# The cloud.id setting overwrites the `output.elasticsearch.hosts` and
# `setup.kibana.host` options.
# You can find the `cloud.id` in the Elastic Cloud web UI.
#cloud.id:

# The cloud.auth setting overwrites the `output.elasticsearch.username` and
# `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
#cloud.auth:

#================================ Outputs =====================================

# Configure what output to use when sending the data collected by the beat.

#-------------------------- Elasticsearch output ------------------------------
#output.elasticsearch:
  # Array of hosts to connect to.
  #hosts: ["localhost:9200"]

  # Optional protocol and basic auth credentials.
  #protocol: "https"
  #username: "elastic"
  #password: "changeme"

#----------------------------- Logstash output --------------------------------
output.logstash:
  # The Logstash hosts
  hosts: ["elk-vm:5044"]

  # Optional SSL. By default is off.
  # List of root certificates for HTTPS server verifications
  #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

  # Certificate for SSL client authentication
  #ssl.certificate: "/etc/pki/client/cert.pem"

  # Client Certificate Key
  #ssl.key: "/etc/pki/client/cert.key"

I'm pretty stumped. All help is appreciated. If there are other logs that people need just let me know.

Hi @johnbchron,

With -E output.elasticsearch.hosts=["localhost:9200"]' you are telling metricbeat to install the templates in an Elasticsearch listening in localhost:9200, in your local machine. I guess you don't have Elasticsearch running in your local machine, you should put there the host where Elasticsearch is running.

Take into account that for the logging use case with filebeat in principle you don't need Logstash, and filebeat is easier to setup when it can send events directly to Elasticsearch. Is there any reason why you need Logstash?

I fixed it... it was actually that I hadn't configured the kibana host correctly in metricbeat.yml. Thanks for your help Jaime.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.