# How to store longer json strings in tag history?

**URL:** <https://forum.inductiveautomation.com/t/how-to-store-longer-json-strings-in-tag-history/56324>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [February 18, 2022, 7:54pm UTC](https://forum.inductiveautomation.com/t/how-to-store-longer-json-strings-in-tag-history/56324 "2022-02-18T19:54:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![djs](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@djs](https://forum.inductiveautomation.com/u/djs)\
**Post date:** [February 18, 2022, 7:54pm UTC](https://forum.inductiveautomation.com/t/how-to-store-longer-json-strings-in-tag-history/56324/1 "2022-02-18T19:54:11Z")

</div>

Hello,

I have the gateway receiving SNMP traps (through Kymera’s SNMP driver) and initially I converted the trap message to a string and wrote it to a _String_ tag. The tag stores it, but the historian refuses to take it, throwing errors that the string is too long. I tried splitting the trap into 2 parts, but it would still sometimes be too long and wouldn’t store in history…

```auto
java.lang.RuntimeException: java.sql.BatchUpdateException: String or binary data would be truncated in table ' *********************************************', column 'stringvalue'. Truncated value: '{1.3.6.1.4.1.9.9.41.1.2.3.1.5.456: Interface GigabitEthernet0/17, changed state to down, 1.3.6.1.6.3'.

```

(Table name has been removed from above log message)

I then tried changing the tag type to _Document_ and storing the information as a json. The tag write is successful again, but now I get this error:

```auto
java.lang.RuntimeException: com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from UNKNOWN to VARCHAR is unsupported.

```

If neither a longer string or a json tag are able to store history, the only way I see to move forward is to either brake down the trap into even smaller bits and write to multiple tags, or to store the trap string and the timestamp myself with a named query…

Has anyone had similar problems with storing tag history? Is there some detail that i’m missing or something that I’ve misconfigured?

I appreciate any input.

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [February 18, 2022, 8:22pm UTC](https://forum.inductiveautomation.com/t/how-to-store-longer-json-strings-in-tag-history/56324/2 "2022-02-18T20:22:47Z")

</div>

The historian uses VARCHAR(255), or the equivalent of your flavor of SQL. You could try changing that, but its probably not a good idea, especially not if you have partitioning enabled. You could write your data to a table of your own design with scripting.

This thread has some good info that may help:  
([Storing Datasets in MySQL Blobs](https://forum.inductiveautomation.com/t/storing-datasets-in-mysql-blobs/19905))

---

<div class="post-metadata">

**Author:** ![David\_Lopez](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@David\_Lopez](https://forum.inductiveautomation.com/u/David_Lopez)\
**Post date:** [August 27, 2024, 3:58pm UTC](https://forum.inductiveautomation.com/t/how-to-store-longer-json-strings-in-tag-history/56324/3 "2024-08-27T15:58:55Z")

</div>

Hello @djs I'm new on SNMP traps, would you mind sharing your knowledge or any documentation on how to integrate them to Ignition please. It would be really appreciated.

---

<div class="post-metadata">

**Author:** ![djs](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@djs](https://forum.inductiveautomation.com/u/djs)\
**Post date:** [August 27, 2024, 9:44pm UTC](https://forum.inductiveautomation.com/t/how-to-store-longer-json-strings-in-tag-history/56324/4 "2024-08-27T21:44:41Z")

</div>

I didn't really end up utilizing traps, so I'm not an expert in them either.

To set up SNMP traps, you need SNMP agents and an SNMP manager. The agents send the traps, and the manager is a server that can receive them. Capable networked devices can be set up to act as agents, and you have to configure them to know what events to alert on and where to send those alerts. The specific details of what that looks like will differ between vendors and types of devices.

If you already have agents configured, and want a manager in Ignition, you could:

- set up your own through python with a [3rd party SNMP library](https://pysnmp.readthedocs.io/en/latest/) in an [externally running python script](https://forum.inductiveautomation.com/t/python-code-check/56329/6) or a [gateway script](https://forum.inductiveautomation.com/t/udp-driver-altering-data/10322/6).
- write a custom module in java utilizing a [3rd party SNMP library](https://www.snmp4j.org/).
- utilize an existing 3rd party module, such as [Kymera's SNMP driver](https://inductiveautomation.com/moduleshowcase/module/kymera-systems-inc-kymera-snmp-driver). Kymera's solution will fire a script whenever a trap is received and it is up to you to write the code and decide what to do with the contents.

(This list is not exhaustive)

---

<div class="post-metadata">

**Author:** ![David\_Lopez](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@David\_Lopez](https://forum.inductiveautomation.com/u/David_Lopez)\
**Post date:** [September 3, 2024, 9:19pm UTC](https://forum.inductiveautomation.com/t/how-to-store-longer-json-strings-in-tag-history/56324/5 "2024-09-03T21:19:29Z")

</div>

Hello @djs, thank you so much for your response. Actually, I have configured UPS as SNMP agents and I'm using the Kymera's SNMP driver, I'm curious about the fired script that you mentioned. I guess there are some system funcitons to use, do you have any aproach or example about that?

---

<div class="post-metadata">

**Author:** ![djs](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@djs](https://forum.inductiveautomation.com/u/djs)\
**Post date:** [September 4, 2024, 5:24pm UTC](https://forum.inductiveautomation.com/t/how-to-store-longer-json-strings-in-tag-history/56324/6 "2024-09-04T17:24:49Z")

</div>

You should really reach out to Kymera; they can give you up-to-date advice and documentation on their module. Also, I believe @Kyle_Chase is from Kymera and a user of the forum if he wants to chime in.

In the designer, under _scripting_, you'll have _Snmp Events_, which open up their script workspace. In there, you can add a script, and then fill in with available functions from the "binding" icon in the top-right. Basically, all the information is in a `trapParameters` variable that has a bunch of "getter" methods. Here's an example script:

```python
tp = trapParameters
ver = tp.getVersion()
reqId = tp.getRequestId()
listAdd = tp.getListenerAddress()
oid = tp.getTrapOid()
ts = tp.getTimestamp()
map = tp.getVariableMap()
source = tp.getSourceAddress()
args = [ver, source, reqId, listAdd, oid, ts, map]
system.util.getLogger("snmp").info(str(args))

```

But you should really reach out to Kymera themselves for complete documentation.

---

<div class="post-metadata">

**Author:** ![David\_Lopez](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@David\_Lopez](https://forum.inductiveautomation.com/u/David_Lopez)\
**Post date:** [September 6, 2024, 3:23am UTC](https://forum.inductiveautomation.com/t/how-to-store-longer-json-strings-in-tag-history/56324/7 "2024-09-06T03:23:53Z")

</div>

Thank you so much for that example and the advice, you have helped me a lot !!  
Best Regards,
