Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts: update server queries to account for system tenant id #109727

Merged
merged 1 commit into from
Aug 31, 2023

Conversation

Santamaura
Copy link
Contributor

@Santamaura Santamaura commented Aug 30, 2023

Previously, ts queries would consider providing no tenant id and the system tenant id as the same and would return all the aggregated datapoints. This was likely due to the original implementation considering that the system tenant would always want to view all the aggregated data.

This is not the case anymore since the system tenant has the ability to view all the data, system tenant specific data or other tenants data. Therefore this commit adjusts the server query code so that if a system tenant id is provided, it returns data for only the system tenant.

Fixes #108929

Release note (bug fix): adjust ts server queries
to be able to return system tenant only metrics if tenant id is provided, this will fix an issue where some metrics graphs appear to double count.

Some screenshots after the change:
All
Screenshot 2023-08-30 at 10 59 50 AM

System
Screenshot 2023-08-30 at 11 00 25 AM

Tenant
Screenshot 2023-08-30 at 11 00 13 AM

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@Santamaura Santamaura marked this pull request as ready for review August 30, 2023 17:24
@Santamaura Santamaura requested a review from a team as a code owner August 30, 2023 17:24
@Santamaura Santamaura requested review from a team and ericharmeling and removed request for a team August 30, 2023 17:24
Copy link
Contributor

@ericharmeling ericharmeling left a comment

Choose a reason for hiding this comment

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

Nice! Just have a few minor comments

Reviewed 1 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Santamaura)


pkg/ts/query.go line 928 at r1 (raw file):

		} else if tenantSource == tenantID.String() {
			rows = append(rows, row)
		}

nit

Suggestion:

		if tenantID.IsSystem() && tenantSource == "" || tenantSource == tenantID.String() {
			rows = append(rows, row)
		}

pkg/ts/server_test.go line 416 at r1 (raw file):

		Queries: []tspb.Query{
			{
				Name:    "test.metric",

Specifying no source aggregates across all sources too. This is a bit confusing and probably worth adding a comment on this test (and the one below).

I don't know what a "source" means in this context, but I'm guessing it's a node? Also worth clarifying.


pkg/ts/server_test.go line 432 at r1 (raw file):

	require.Equal(t, expectedAggregatedResult, aggregatedResponse)

	// Ssytem tenant ID should provide system tenant ts data.

nit

Suggestion:

System

Previously, ts queries would consider providing no
tenant id and the system tenant id as the same and
would return all the aggregated datapoints. This was
likely due to the original implementation considering
that the system tenant would always want to view all
the aggregated data.

This is not the case anymore since the system tenant has
the ability to view all the data, system tenant specific data
or other tenants data. Therefore this commit adjusts the server
query code so that if a system tenant id is provided, it returns
data for only the system tenant.

Fixes cockroachdb#108929

Release note (bug fix): adjust ts server queries
to be able to return system tenant only metrics if tenant
id is provided, this will fix an issue where some metrics
graphs appear to double count.
Copy link
Contributor Author

@Santamaura Santamaura left a comment

Choose a reason for hiding this comment

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

TFTR

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ericharmeling)


pkg/ts/query.go line 928 at r1 (raw file):

Previously, ericharmeling (Eric Harmeling) wrote…

nit

D


pkg/ts/server_test.go line 432 at r1 (raw file):

Previously, ericharmeling (Eric Harmeling) wrote…

nit

Done

Copy link
Contributor Author

@Santamaura Santamaura left a comment

Choose a reason for hiding this comment

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

Weird reviewable did not post some of my comments, redid those ones.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ericharmeling)


pkg/ts/query.go line 928 at r1 (raw file):

Previously, Santamaura (Alex Santamaura) wrote…

D

Done


pkg/ts/server_test.go line 416 at r1 (raw file):

Previously, ericharmeling (Eric Harmeling) wrote…

Specifying no source aggregates across all sources too. This is a bit confusing and probably worth adding a comment on this test (and the one below).

I don't know what a "source" means in this context, but I'm guessing it's a node? Also worth clarifying.

Added comments to the tests, source is nodeID or storeID

@Santamaura
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Aug 31, 2023

Build succeeded:

@yuzefovich
Copy link
Member

blathers backport 23.1

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.

multitenant: timeseries double counts some metrics
4 participants