I am using an Azure CosmosDB with the Cassandra API to store traces from Jaeger. I have been able to create the schema and data is saving correctly, however when I search the traces in Grafana, I get the following error:
ORDER BY requires creating a custom index: CosmosClusteringIndex. Please create a custom index and re-issue this query
The query being run is:
SELECT * FROM jaegertracing.service_name_index WHERE bucket in (0,1,2,3,4,6,7,8,9) AND service_name = 'my-service' AND start_time > 1718728568730810 AND start_time < 1718728668730810 ORDER BY start_time DESC;
The table creation CQL is:
CREATE TABLE IF NOT EXISTS jaegertracing.service_name_index (
service_name text,
bucket int,
start_time bigint, -- microseconds since epoch
trace_id blob,
PRIMARY KEY ((service_name, bucket), start_time)
) WITH CLUSTERING ORDER BY (start_time DESC)
AND compaction = {
'compaction_window_size': '1',
'compaction_window_unit': 'HOURS',
'class': 'org.apache.cassandra.db.compaction.TimeWindowCompactionStrategy'
}
AND default_time_to_live = ${trace_ttl}
AND speculative_retry = 'NONE'
AND gc_grace_seconds = 0;
Is there any way to resolve this error? I have tried adding a secondary index but that doesn't work. Perhaps changing the primary key or clustering order? I am not particularly familiar with Cassandra so if there is a workaround it would be appreciated.