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

Add per-tenant request counter metric to index gateway server #9797

Merged
merged 4 commits into from
Jun 27, 2023

Conversation

chaudum
Copy link
Contributor

@chaudum chaudum commented Jun 26, 2023

This commit add a counter metric with labels operation, tenant, status for gRPC requests that are served by the index gateway.

What for?

The per-tenant RPS on the index gateway is used to derive the per-tenant shard factor.

Why tracking on the server?

Unlike tracking index gateway RPS on the client side, tracking on the server side does not yield that many series, even in multi-tenant installations with a lot of tenants, because the amout of index gateway instances is relatively small compared to the amount of queriers and frontends.

Special notes for your reviewer:

The previous approach of tracking requests on the client #9781 has been abandoned.

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated
    • If the change is worth mentioning in the release notes, add add-to-release-notes label
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/upgrading/_index.md
  • For Helm chart changes bump the Helm chart version in production/helm/loki/Chart.yaml and update production/helm/loki/CHANGELOG.md and production/helm/loki/README.md. Example PR

chaudum added 2 commits June 26, 2023 15:38
This commit add a counter metric with labels `operation`, `tenant`,
`status` for gRPC requests that are served by the index gateway.

What for?

The per-tenant RPS on the index gateway is used to derive the per-tenant
shard factor.

Why tracking on the server?

Unlike tracking index gateway RPS on the client side, tracking on the
server side does not yield that many series, even in multi-tenant
installations with a lot of tenants, because the amout of index gateway
instances is relatively small compared to the amount of queriers and
frontends.

Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
@chaudum chaudum force-pushed the chaudum/index-gw-instrumentation branch from 11d2b44 to f42c249 Compare June 26, 2023 13:40
@chaudum chaudum requested review from DylanGuedes and owen-d June 26, 2023 13:40
@chaudum chaudum marked this pull request as ready for review June 26, 2023 13:40
@chaudum chaudum requested a review from a team as a code owner June 26, 2023 13:40
Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
Copy link
Contributor

@sandeepsukhani sandeepsukhani left a comment

Choose a reason for hiding this comment

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

left a minor nit but other than that it LGTM

@@ -1242,6 +1244,15 @@ func (t *Loki) initIndexGatewayRing() (_ services.Service, err error) {
return t.indexGatewayRingManager, nil
}

func (t *Loki) initIndexGatewayInterceptors() (services.Service, error) {
// Only expose per-tenant metric if index gateway runs as standalone service
if util.StringsContain(t.Cfg.Target, IndexGateway) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We actually use this to check if the module was set in the targets. Although it does the same thing under the hood, it would be good to keep things consistent.

Suggested change
if util.StringsContain(t.Cfg.Target, IndexGateway) {
if t.Cfg.isModuleEnabled(IndexGateway) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not check the function implementation and thought it that it would also return true if the module is a dependency of the target. I think the function name is slightly misleading.

Of course, I will apply your suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, the naming is confusing. This one checks if the user explicitly enabled the module in the targets flag. There is also isModuleActive which checks if the module would be initialized.

Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
@chaudum chaudum merged commit a65c99d into main Jun 27, 2023
@chaudum chaudum deleted the chaudum/index-gw-instrumentation branch June 27, 2023 07:21
chaudum added a commit that referenced this pull request Jun 27, 2023
This commit add a counter metric `loki_index_gateway_requests_total` with labels `operation`, `tenant`, `status` for gRPC requests that are served by the index gateway.

**What for?**

The per-tenant RPS on the index gateway is used to derive the per-tenant shard factor.

**Why tracking on the server?**

Unlike tracking index gateway RPS on the client side, tracking on the server side does not yield that many series, even in multi-tenant installations with a lot of tenants, because the amount of index gateway instances is relatively small compared to the amount of queriers and frontends.

**Special notes for your reviewer**:

The previous approach of tracking requests on the client #9781 has been abandoned.


Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
chaudum added a commit that referenced this pull request Jun 27, 2023
…#9804)

**This is a backport of #9797 to k156**

---

This commit add a counter metric `loki_index_gateway_requests_total`
with labels `operation`, `tenant`, `status` for gRPC requests that are
served by the index gateway.

**What for?**

The per-tenant RPS on the index gateway is used to derive the per-tenant
shard factor.

**Why tracking on the server?**

Unlike tracking index gateway RPS on the client side, tracking on the
server side does not yield that many series, even in multi-tenant
installations with a lot of tenants, because the amount of index gateway
instances is relatively small compared to the amount of queriers and
frontends.

**Special notes for your reviewer**:

The previous approach of tracking requests on the client
#9781 has been abandoned.

Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants