<p>I want to use one logstash send data to multiple logstash services.</p>
<p>If I use this setting in k8s, it can work.</p>
<p>service.yml</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  labels:
    app: logstash
  name: logstash
spec:
  selector:
    app: logstash
  ports:
    - name: &quot;5044&quot;
      port: 5044
      targetPort: 5044
</code></pre>
<p>filebeat.yml</p>
<pre><code>    filebeat.inputs:
      - type: log
        enabled: true
        paths:
          - /var/log/log1.json
        tags: [&quot;log1&quot;]

    processors:
      - decode_json_fields:
          fields: [&quot;message&quot;]
          process_array: true
          max_depth: 1
          target: &quot;&quot;
          overwrite_keys: true
          add_error_key: false

    output.logstash:
      hosts: [&quot;logstash-log1.default.svc.cluster.local:5044&quot;]
</code></pre>
<p>logstash.yml</p>
<pre><code>---
apiVersion: v1
kind: ConfigMap
metadata:
  name: configmap-logstash
data:
  logstash.yml: |
    http.host: &quot;0.0.0.0&quot;
    path.config: /usr/share/logstash/pipeline
    xpack.monitoring.enabled: false
  logstash.conf: |
    input {
      beats {
        port =&gt; 5044
      }
    }

    filter {
    }

    output {
      stdout { codec =&gt; rubydebug }
    }

</code></pre>
<p>But if I change to another way, set output from another logstash instance as:</p>
<p>k8s services:</p>
<pre><code>---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: logstash-log1
  name: logstash-log1
spec:
  selector:
    app: logstash-log1
  ports:
    - name: &quot;5044&quot;
      port: 5044
      targetPort: 5044
</code></pre>
<p>logstash.yml</p>
<pre><code>    output {
      if &quot;log1&quot; in [tags] {
        stdout { codec =&gt; rubydebug }
        tcp {
          mode =&gt; &quot;client&quot;
          host =&gt; &quot;logstash-log1.default.svc.cluster.local&quot;
          port =&gt; 5044
          codec =&gt; &quot;json&quot;
        }
      }
    }
</code></pre>
<p>target logstash's logstash.yml</p>
<pre><code>---
apiVersion: v1
kind: ConfigMap
metadata:
  name: configmap-logstash
data:
  logstash.yml: |
    http.host: &quot;0.0.0.0&quot;
    path.config: /usr/share/logstash/pipeline
    xpack.monitoring.enabled: false
  logstash.conf: |
    input {
      tcp {
        port =&gt; 5044
      }
    }

    filter {
    }

    output {
      stdout { codec =&gt; rubydebug }
    }

</code></pre>
<p>The communication can be confimed, it works. But the data seems didn't send to <code>logstash-log1.default.svc.cluster.local:5044</code>.</p>
<p>If use curl to test from origin logstash,</p>
<pre><code>curl logstash-log1.default.svc.cluster.local:5044
</code></pre>
<p>Can get log data in the target logstash:</p>
<pre><code>{
  &quot;port&quot; =&gt; 37424,
  &quot;host&quot; =&gt; &quot;10.12.8.213&quot;
}
{
  &quot;port&quot; =&gt; 37424,
  &quot;host&quot; =&gt; &quot;10.12.8.213&quot;
}
{
  &quot;port&quot; =&gt; 37424,
  &quot;host&quot; =&gt; &quot;10.12.8.213&quot;
}
{
  &quot;port&quot; =&gt; 37424,
  &quot;host&quot; =&gt; &quot;10.12.8.213&quot;
}
</code></pre>
<p>So the problem may be the configuration between 2 logstash. Doesn't tcp input/output methods work?</p>

iooi
<p>Try using the <a href="https://www.elastic.co/guide/en/logstash/current/plugins-outputs-lumberjack.html" rel="nofollow noreferrer"><code>lumberjack</code> output</a> and <a href="https://www.elastic.co/guide/en/logstash/current/plugins-inputs-beats.html" rel="nofollow noreferrer"><code>beats</code> input</a>.</p>
<p>This is the recommended approach for Logstash-to-Logstash communication, and is explained in detail <a href="https://www.elastic.co/guide/en/logstash/current/ls-to-ls.html" rel="nofollow noreferrer">here</a> in the logstash docs.</p>
