Skip to content

CH-38 - Introduce deployment ID for unique telemetry identification and tracking.#45

Open
SammyOina wants to merge 6 commits intoabsmach:mainfrom
SammyOina:unique-deployment
Open

CH-38 - Introduce deployment ID for unique telemetry identification and tracking.#45
SammyOina wants to merge 6 commits intoabsmach:mainfrom
SammyOina:unique-deployment

Conversation

@SammyOina
Copy link
Copy Markdown
Contributor

@SammyOina SammyOina commented Nov 24, 2025

What does this do?

This PR introduces a deployment ID field to uniquely identify Magistrala deployments in the telemetry system, moving away from IP-based identification which can be unreliable due to NAT, dynamic IPs, or multiple deployments behind the same IP. The deployment ID can be configured via environment variables or is automatically generated and persisted to disk.

Which issue(s) does this PR fix/relate to?

Resolves #38

List any changes that modify/break current functionality

Have you included tests for your changes?

Did you document any new/modified functionality?

Notes

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a deployment ID field to uniquely identify Magistrala deployments in the telemetry system, moving away from IP-based identification which can be unreliable due to NAT, dynamic IPs, or multiple deployments behind the same IP. The deployment ID can be configured via environment variables or is automatically generated and persisted to disk.

Key changes:

  • Added deployment_id field to telemetry data model and database schema with migration
  • Implemented deployment ID retrieval logic with fallback: environment variable → file → generate new UUID
  • Updated all SQL queries to use COALESCE(deployment_id, ip_address) for backward compatibility

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
telemetry.go Added DeploymentID field to the Telemetry struct with appropriate struct tags
pkg/client/client.go Implemented getDeploymentID() function to retrieve/generate deployment ID from environment variables or file, and integrated it into the telemetry collection
timescale/init.go Added migration telemetry_7 to add deployment_id column and create index
timescale/timescale.go Updated all queries (RetrieveAll, Save, RetrieveSummary) to use deployment_id with COALESCE fallback to ip_address for backward compatibility

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/client/client.go
Comment thread pkg/client/client.go
Comment thread pkg/client/client.go
Comment thread timescale/init.go Outdated
… tracking.

Signed-off-by: Sammy Oina <sammyoina@gmail.com>
Signed-off-by: Sammy Oina <sammyoina@gmail.com>
…ved request handling

Signed-off-by: Sammy Oina <sammyoina@gmail.com>
…sistency

Signed-off-by: Sammy Oina <sammyoina@gmail.com>
… creation for telemetry

Signed-off-by: Sammy Oina <sammyoina@gmail.com>
Signed-off-by: Sammy Oina <sammyoina@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make deployment fingerprint to avoid duplicate telemetry

2 participants