adminQuotas.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import {Fragment} from 'react';
  2. import TextField from 'sentry/components/forms/fields/textField';
  3. import InternalStatChart from 'sentry/components/internalStatChart';
  4. import Panel from 'sentry/components/panels/panel';
  5. import PanelBody from 'sentry/components/panels/panelBody';
  6. import PanelHeader from 'sentry/components/panels/panelHeader';
  7. import {t} from 'sentry/locale';
  8. import DeprecatedAsyncView from 'sentry/views/deprecatedAsyncView';
  9. type Config = {
  10. backend: string;
  11. options: Record<string, string>;
  12. };
  13. type State = DeprecatedAsyncView['state'] & {
  14. config: Config;
  15. resolution: string;
  16. since: number;
  17. };
  18. export default class AdminQuotas extends DeprecatedAsyncView<{}, State> {
  19. getDefaultState() {
  20. return {
  21. ...super.getDefaultState(),
  22. since: new Date().getTime() / 1000 - 3600 * 24 * 7,
  23. resolution: '1h',
  24. };
  25. }
  26. getEndpoints(): ReturnType<DeprecatedAsyncView['getEndpoints']> {
  27. return [['config', '/internal/quotas/']];
  28. }
  29. renderBody() {
  30. const {config} = this.state;
  31. return (
  32. <Fragment>
  33. <h3>Quotas</h3>
  34. <Panel>
  35. <PanelHeader>{t('Config')}</PanelHeader>
  36. <PanelBody withPadding>
  37. <TextField
  38. name="backend"
  39. value={config.backend}
  40. label="Backend"
  41. disabled
  42. inline={false}
  43. stacked
  44. />
  45. <TextField
  46. name="rateLimit"
  47. value={config.options['system.rate-limit']}
  48. label="Rate Limit"
  49. disabled
  50. inline={false}
  51. stacked
  52. />
  53. </PanelBody>
  54. </Panel>
  55. <Panel>
  56. <PanelHeader>{t('Total Events')}</PanelHeader>
  57. <PanelBody withPadding>
  58. <InternalStatChart
  59. since={this.state.since}
  60. resolution={this.state.resolution}
  61. stat="events.total"
  62. label="Events"
  63. />
  64. </PanelBody>
  65. </Panel>
  66. <Panel>
  67. <PanelHeader>{t('Dropped Events')}</PanelHeader>
  68. <PanelBody withPadding>
  69. <InternalStatChart
  70. since={this.state.since}
  71. resolution={this.state.resolution}
  72. stat="events.dropped"
  73. label="Events"
  74. />
  75. </PanelBody>
  76. </Panel>
  77. </Fragment>
  78. );
  79. }
  80. }