When writing records to a custom ControlUp Edge data index via the REST API (POST to edge/api/data/), users may encounter an issue where repeated writes of the same record result in duplicate entries rather than updates to existing records. Additionally, there is a desire to prevent these records from expiring after the default 28 days of inactivity. This discussion sheds light on both the mechanics of record updating and the association of records with the endpoint running the write operation.
The key to controlling whether a record is created anew or updated lies in the uniqueness of the “key” field or primary identifier used in the data index schema. When writing data via a PowerShell script—whether executed inside ControlUp or externally—the operation will create a new record if the key value is not recognized. To update an existing record, the key must remain consistent and the write must explicitly target that key. The official ControlUp scripting guide provides useful guidance for writing data to an index, outlining how to structure the payload and use keys: https://support.controlup.com/docs/scripting-guide#writing-to-a-data-index. Running the script inside ControlUp offers the advantage of on-demand execution with local file availability, but it is not strictly necessary; scripts can also run externally.
A practical complication arises from the fact that data written to the index often becomes associated with the endpoint where the script executes, as seen when the computer name appears linked to each record. This behavior stems from ControlUp’s design, where data sources are tied to machine endpoints to facilitate monitoring and troubleshooting. In scenarios where building information needs to be stored independently of endpoint context, some organizations have implemented custom solutions such as storing building data locally on endpoints (e.g., in registry or Active Directory properties), then running scripts on each endpoint to gather and send this data to ControlUp. While this approach inherently associates data with those endpoints, it maintains up-to-date building information across the environment.
Controlling record expiration beyond the default 28 days typically requires adjusting settings on the data index or implementing regular writes to keep the record active. Without ongoing updates, ControlUp’s retention policy will remove inactive records. Users are also encouraged to explore ControlUp Workflows for automating data collection and writing processes, which can streamline operations despite a learning curve. The ControlUp support team and community forums remain valuable resources for addressing specific scripting and data index challenges.
For additional details and sample scripts, the ControlUp scripting guide is recommended: https://support.controlup.com/docs/scripting-guide#writing-to-a-data-index.
Read the entire ‘How to Update Records Without Duplication and Manage Retention in Custom ControlUp Edge Data Indexes’ thread below:
Hi everyone. We’re writing building records to a custom ControlUp Edge index (POST to edge/api/data/). How do we write a record so that running the same write again updates that same record instead of creating a duplicate, while still keeping it from expiring after 28 days of inactivity?
You can achieve this by using a PowerShell script inside CU.
https://support.controlup.com/docs/scripting-guide#writing-to-a-data-index
Thanks, Rico. I’ll take look. I am running this PowerShell script outside of ControlUp. I am running it from my computer along side a CSV file. I’ll read the link you gave now.
Hi Arthur,
I believe Rico suggested running the script from within ControlUp, where this option should be available.
But it won’t be ran from a endpoint.
We are populating a brand new index with building info.
Perhaps has had some experience with this
So I have a PowerShell script that reads a CSV file and populates with address, building name, and coordinates.
When I run the script a second time, it just creates a second duplicate record.
I’ve already pinged him on the side, but also asking the community
You should be able to run this from ControlUp, on demand, as long as the required csv is at the same location as the script is expecting.
Yeah…. that can work.
Maybe a Workflow can help with this
I love Workflows, but the learning curve is just not fun!
the whole data query part is just go difficult to grasp.
Consider it as a nice learning path :).. it can be hard, I agree! Support is very helpful if you encounter some issues!
and ofc this comm!
I like your idea even more Abel!
That should work.
it did run, but now my computer name is associated with each record.
I just need this to be an index that holds building info.
when I worked with customers they stored build information locally on every machine in some custom registry + ad object properties for the machine. They had a script run every day on the endpoint gathering the data and writing it away. Data will always be associated with the endpoint the script runs on
Continue reading and comment on the thread ‘How to Update Records Without Duplication and Manage Retention in Custom ControlUp Edge Data Indexes’. Not a member? Join Here!
Categories: All Archives
