# Timestamps accidentally inserted as tags

**URL:** <https://community.influxdata.com/t/timestamps-accidentally-inserted-as-tags/30669>\
**Category:** Systems\
**Tags:** influxdb, schema, performance\
**Created:** [July 11, 2023, 1:43pm UTC](https://community.influxdata.com/t/timestamps-accidentally-inserted-as-tags/30669 "2023-07-11T13:43:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![grigolet](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/grigolet/32/13873_2.png) [@grigolet](https://community.influxdata.com/u/grigolet)\
**Post date:** [July 11, 2023, 1:43pm UTC](https://community.influxdata.com/t/timestamps-accidentally-inserted-as-tags/30669/1 "2023-07-11T13:43:55Z")

</div>

Hello,  
I have a kind of general question on how to deal with the following issue:  
we have InfluxDB OSS 1.8.x and in one measurements we have stored by mistake the timestamp of each row as a tag value every 10 seconds for 10 days. This resulted in a large amount of tag values for the tag key `timestamp`. When trying to retrieve them, the database gets probably overloaded and starts dropping connections and refusing to execute queries.

I would like to somehow fix this issue. I know it’s not possible to remove the tags because they are part of the definition of a series. However, is there any strategy, for example by dumping data locally, deleting the one of the DB and then restoring it, or a query to duplicate only the fields, that allows me to get rid of those tag values?

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [July 12, 2023, 9:16pm UTC](https://community.influxdata.com/t/timestamps-accidentally-inserted-as-tags/30669/2 "2023-07-12T21:16:39Z")

</div>

Hello @grigolet,  
You could try dropping the wrong series and then rewriting your data:

> **[Manage your database using InfluxQL | InfluxDB OSS 1.8 Documentation](https://docs.influxdata.com/influxdb/v1.8/query_language/manage-database/#drop-series-from-the-index-with-drop-series)**
>
> Use InfluxQL to administer your InfluxDB server and work with InfluxDB databases, retention policies, series, measurements, and shards.

Where you don’t have incorrect tags.  
Or depending on how much data you have you could use a client library to query the good data and then rewrite it to a new instance.

---

<div class="post-metadata">

**Author:** ![grigolet](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/grigolet/32/13873_2.png) [@grigolet](https://community.influxdata.com/u/grigolet)\
**Post date:** [July 13, 2023, 7:24am UTC](https://community.influxdata.com/t/timestamps-accidentally-inserted-as-tags/30669/3 "2023-07-13T07:24:03Z")

</div>

Hello @Anaisdg ,  
thanks for the hint!  
I eneded up doing the following:

Assuming to have a database `test` and a measurement `mymeasurement` with the following definition:

```auto
# DDL
CREATE DATABASE test
# DML
# CONTEXT-DATABASE: test
mymeasurement,host=myhost value=1.0 1689230446
mymeasurement,host=myhost value=2.0 1689230447 
mymeasurement,host=myhost value=2.0 1689230448 
mymeasurement,host=myhost value=2.0 1689230449
mymeasurement,host=myhost value=4.0 1689230450
mymeasurement,host=myhost value=5.0 1689230451
mymeasurement,host=myhost,timestamp=1689230452 value=1.0 1689230452
mymeasurement,host=myhost,timestamp=1689230453 value=2.0 1689230453
mymeasurement,host=myhost,timestamp=1689230454 value=3.0 1689230454
mymeasurement,host=myhost,timestamp=1689230455 value=4.0 1689230455
mymeasurement,host=myhost,timestamp=1689230456 value=5.0 1689230456

```

- Query the data with the `timestamp` tag set and dumping it to a text file. Something like

```auto
influx -database test -execute "select * from mymeasurement where timestamp != '' " -format 'csv' > data_with_timestamp.csv

```

Which resulted in this:

```auto
name,time,host,timestamp,value
mymeasurement,1689230452000000000,myhost,1689230452,1
mymeasurement,1689230453000000000,myhost,1689230453,2
mymeasurement,1689230454000000000,myhost,1689230454,3
mymeasurement,1689230455000000000,myhost,1689230455,4

```

- Drop the series containing a timestamp:

```auto
influx -database test -execute "drop series from mymeasurement where timestamp != ''"

```

- Fix the data in `data_with_timestamp.csv` file by removing the timestamp tag/values and then reimport the data with whatever tool
