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

[vtadmin-web] Add QPS and VReplicationQPS charts to Tablet view #8263

Merged
merged 1 commit into from
Jun 5, 2021

Conversation

doeg
Copy link
Contributor

@doeg doeg commented Jun 4, 2021

Signed-off-by: Sara Bee 855595+doeg@users.noreply.github.com

Description

As the title says! This updates the Tablet view with QPS and VReplication QPS charts, which query the /debug/vars tablet endpoint.

I will almost certainly + indefinitely shuffle around the layout of the Tablet view but what else is new!

Here's what a cutover looks like. 🔪 ✨

Screen Shot 2021-06-04 at 9 51 31 AM

Screen Shot 2021-06-04 at 9 51 26 AM

Related Issue(s)

N/A

Checklist

  • Tests were added or are not required
  • Documentation was added or is not required

Deployment Notes

N/A

Signed-off-by: Sara Bee <855595+doeg@users.noreply.github.com>
Comment on lines +77 to +116
export const formatTimeseriesMap = (rates: { [k: string]: number[] }, endAt?: number): TimeseriesMap => {
// Rates stats are (unfortunately) not returned with timestamps, so we infer them here.
// This behaviour matches that of the vtctld2 UI:
// https://github.com/vitessio/vitess/blob/main/go/vt/vttablet/tabletserver/status.go#L178
const _endAt = typeof endAt === 'number' ? endAt : Date.now();

// The `rates` map returned from the API, keyed by series name, will either:
// (a) be empty, or
// (b) contain a minimum of two series, one of them named "All".
// In the first case, inserting an empty "All" series renders more nicely
// on a Highcharts graph since it will include the axes, etc. So, we add it here.
const _rates = !!Object.keys(rates).length ? rates : { All: [] };

const planTypes = Object.keys(_rates);

const data: TimeseriesMap = {};

// This logic is borrowed from the vtctld2 UI
// https://github.com/vitessio/vitess/blob/09e74af/go/vt/vttablet/tabletmanager/vreplication/stats.go#L478-L505
for (let i = 0; i < RATES_MAX_SPAN / RATES_INTERVAL; i++) {
const x = _endAt - ((i * 60) / RATES_INTERVAL) * 1000;

for (let j = 0; j < planTypes.length; j++) {
// Assume 0.0 QPS for older, non-existent data points.
let y = 0;

if (i < _rates[planTypes[j]].length) {
const idx = _rates[planTypes[j]].length - i - 1;
y = +_rates[planTypes[j]][idx].toFixed(2);
}

if (!Array.isArray(data[planTypes[j]])) {
data[planTypes[j]] = [];
}

data[planTypes[j]].unshift({ x, y });
}
}

return data;
Copy link
Contributor Author

@doeg doeg Jun 4, 2021

Choose a reason for hiding this comment

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

Apart from changing a couple of variable names and adding tests, I lifted this logic from the vtctld2 UI here: https://github.com/vitessio/vitess/blob/09e74af/go/vt/vttablet/tabletmanager/vreplication/stats.go#L478-L505

I came across two potential bugs/inconsistencies that I'll investigate further (outside this PR). In both cases, I decided to match the existing behaviour since at least that's consistent, for now.

  • The vtctld2 logic + comments state that the charts span a 15 minute time range, with data points at 5 second intervals. However, the x-axis on the existing charts (and therefore these new VTAdmin charts) spans ~ 35 minutes:

    Screen Shot 2021-06-04 at 9 55 45 AM

    I think its the x-axis that is correct, and that the data is indeed doing a 15 minute span with a 5 second sampling interval, however I'll need to more closely investigate how rates work.

  • There seems to be a lurking bug in the aggregation of VReplicationQPS stats. It's tedious to replicate, but the VRep QPS data seems to flip-flop between individual stream rates every few (five?) seconds, rather than aggregating them. This behaviour has a similar feel to Stats: Rates object leaks goroutines #8171, although I'm not sure if it's related. Will follow up. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

@doeg doeg requested a review from ajm188 June 4, 2021 14:00
@doeg doeg marked this pull request as ready for review June 4, 2021 14:00
@doeg doeg added this to In progress in VTAdmin via automation Jun 4, 2021
@doeg doeg added Component: VTAdmin VTadmin interface Type: Enhancement Logical improvement (somewhere between a bug and feature) labels Jun 4, 2021
Copy link
Contributor

@ajm188 ajm188 left a comment

Choose a reason for hiding this comment

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

lgtm

@ajm188 ajm188 merged commit ecd3abf into vitessio:main Jun 5, 2021
VTAdmin automation moved this from In progress to Done Jun 5, 2021
@doeg doeg deleted the sarabee-vtadmin-tablet-viz branch June 5, 2021 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: VTAdmin VTadmin interface Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants