# Formatting problems when I import a metricbeat index from one elastic instance to another

**URL:** https://discuss.elastic.co/t/formatting-problems-when-i-import-a-metricbeat-index-from-one-elastic-instance-to-another/327808
**Category:** Elasticsearch
**Created:** [March 16, 2023, 6:19am UTC](https://discuss.elastic.co/t/formatting-problems-when-i-import-a-metricbeat-index-from-one-elastic-instance-to-another/327808 "2023-03-16T06:19:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![eeijlar](https://avatars.discourse-cdn.com/v4/letter/e/96bed5/32.png) [@eeijlar](https://discuss.elastic.co/u/eeijlar)
#### Post date: [March 16, 2023, 6:19am UTC](https://discuss.elastic.co/t/formatting-problems-when-i-import-a-metricbeat-index-from-one-elastic-instance-to-another/327808/1 "2023-03-16T06:19:00Z")

</div>

I am exporting a metricbeat index from elastic using logstash. I am using the following pipeline:

```auto
    - pipeline.id: export-process
      pipeline.workers: 4
      config.string: |
        input {
          elasticsearch {
            hosts => "http://localhost:9200"
            ssl => "false"
            index => "metricbeat-*"
            docinfo => true
          }
        }

        output {
          file {
            gzip => "true"
            path => "/usr/share/logstash/export/export_%{[@metadata][_index]}.json.gz"
          }
        }

```

Then I am trying to import the resulting json document back into another elastic instance using logstash with this import pipeline:

```auto
    - pipeline.id: import-process
      pipeline.workers: 4
      config.string: |
        input {
          file {
            path => "/usr/share/logstash/export/export_metricbeat-7.17.7-2023.03.15-000001.json"
            start_position => "beginning"
          }
        }

        output {
          elasticsearch {
             hosts => "http://localhost:9200"
             index => "metricbeat-7.17.7-2023.03.15-000001"
             ssl => "false"
          }
        }

```

Unfortunately, when it imports it's not creating the index properly. It looks like this:

```auto
{
  "_index": "metricbeat-7.17.7-2023.03.15-000001",
  "_id": "i3XL5IYBqplkWF1zeYbz",
  "_score": 1,
  "_ignored": [
    "message.keyword"
  ],
  "_source": {
    "@timestamp": "2023-03-15T10:23:05.122Z",
    "@version": "1",
    "path": "/usr/share/logstash/export/export_metricbeat-7.17.7-2023.03.15-000001.json",
    "message": "{\"metricset\":{\"period\":60000,\"name\":\"collector\"},\"@timestamp\":\"2023-03-15T07:31:08.405Z\",\"service\":{\"address\":\"http://udsf-data-repository-db-metrics.udsf-chf.svc.cluster.local:8484/metrics\",\"type\":\"prometheus\"},\"prometheus\":{\"metrics\":{\"voltdb_table_tuple_count\":0,\"voltdb_table_tuple_allocated_memory_bytes\":2097152,\"voltdb_table_inline_tuple_bytes\":0,\"voltdb_table_non_inline_data_bytes\":0},\"labels\":{\"hostname\":\"udsf-data-repository-db-cluster-0\",\"instance\":\"udsf-data-repository-db-metrics.udsf-chf.svc.cluster.local:8484\",\"type\":\"PersistentTable\",\"job\":\"prometheus\",\"tablename\":\"UDSF_COUNT_BY_SESSION_TYPE\",\"partitionid\":\"18\"}},\"agent\":{\"version\":\"7.17.7\",\"hostname\":\"ip-10-10-25-65.eu-west-1.compute.internal\",\"id\":\"ddabf1ce-22f2-4ec6-a4af-e267544b6d5e\",\"type\":\"metricbeat\",\"name\":\"ip-10-10-25-65.eu-west-1.compute.internal\",\"ephemeral_id\":\"47cd9091-51e4-4718-bb38-264e68eccea7\"},\"ecs\":{\"version\":\"1.12.0\"},\"@version\":\"1\",\"host\":{\"name\":\"ip-10-10-25-65.eu-west-1.compute.internal\"},\"event\":{\"module\":\"prometheus\",\"dataset\":\"prometheus.collector\",\"duration\":160809113}}",
    "host": "b70093e9aebc"
  }
}

```

The majority of the document has been dumped under the **message** field. Is there some more transformation I need to do in the pipeline? I just want the document exactly as it was in the original elastic instance.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [March 19, 2023, 10:21pm UTC](https://discuss.elastic.co/t/formatting-problems-when-i-import-a-metricbeat-index-from-one-elastic-instance-to-another/327808/2 "2023-03-19T22:21:30Z")

</div>

Is this the same as [How do I output metadata when exporting data from elasticsearch with logstash?](https://discuss.elastic.co/t/how-do-i-output-metadata-when-exporting-data-from-elasticsearch-with-logstash/327684)?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 16, 2023, 10:21pm UTC](https://discuss.elastic.co/t/formatting-problems-when-i-import-a-metricbeat-index-from-one-elastic-instance-to-another/327808/3 "2023-04-16T22:21:36Z")

</div>

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