Skip to main content
Answer

How to add externalId to a Timeseries

  • August 2, 2023
  • 4 replies
  • 66 views

Peter Quinn
Committed
Forum|alt.badge.img+2

I created a set of timeseries via the API. The Python examples do not show how to include an externalId nor do they say one is really needed. Looks like they need one, otherwise they don’t work in Charts. That’s all fine. My problem now is to add the externalId to existing timeseries.

I think the right way to do this is with a transform, but I can’t get it right. I can get it to preview correctly, but it fails when I run it.

My transform is:

Select
name as name,
concat(name,"123") as externalId
from
`_cdf`.`timeseries`
where dataSetId = 8883655420989208;

The error is Request with id 2463250f-1635-9a05-aa9a-709366e80349 to https://westeurope-1.cognitedata.com/api/v1/projects/rok-buandcollaborators-53/timeseries/update failed with status 400: Time series not found. Missing externalIds: [Tank-401-01-TT123].

Looks like it’s trying to query for the timeseries with that externaId when I’m trying to set the externalId. How do I get it to set the value?

Best answer by Jason Dressel

@Peter Quinn ,

Try adding id to the select clause.  

id is an auto generated, internal identifier.  Yes, as you highlight, it’s good practice to specify an externalId.  externalId must be unique per CDF resource type.
-Jason

4 replies

Forum|alt.badge.img
  • Seasoned Practitioner
  • Answer
  • August 2, 2023

@Peter Quinn ,

Try adding id to the select clause.  

id is an auto generated, internal identifier.  Yes, as you highlight, it’s good practice to specify an externalId.  externalId must be unique per CDF resource type.
-Jason


Peter Quinn
Committed
Forum|alt.badge.img+2
  • Author
  • Committed
  • August 2, 2023

No urgency on this. I removed the TS and recreated them. It would be nice if the docs had an example like

ts = cdf_client.time_series.create(TimeSeries(name=tsname, data_set_id=dataset, external_id=tsname))

 


Peter Quinn
Committed
Forum|alt.badge.img+2
  • Author
  • Committed
  • August 2, 2023

Not just best practice - if you want a timeseries to be visible in Charts, it needs an externalId


  • Seasoned Practitioner
  • August 3, 2023

Hi @Peter Quinn, I have created a ticket for our documentation team. Thank you for the suggestion!