adminQuotas.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import {Fragment, useState} from 'react';
  2. import TextField from 'sentry/components/forms/fields/textField';
  3. import InternalStatChart from 'sentry/components/internalStatChart';
  4. import LoadingError from 'sentry/components/loadingError';
  5. import LoadingIndicator from 'sentry/components/loadingIndicator';
  6. import Panel from 'sentry/components/panels/panel';
  7. import PanelBody from 'sentry/components/panels/panelBody';
  8. import PanelHeader from 'sentry/components/panels/panelHeader';
  9. import {t} from 'sentry/locale';
  10. import {useApiQuery} from 'sentry/utils/queryClient';
  11. type Config = {
  12. backend: string;
  13. options: Record<string, string>;
  14. };
  15. export default function AdminQuotas() {
  16. const {
  17. data: config,
  18. isPending,
  19. isError,
  20. } = useApiQuery<Config>(['/internal/quotas/'], {
  21. staleTime: 0,
  22. });
  23. const [since] = useState(() => new Date().getTime() / 1000 - 3600 * 24 * 7);
  24. const resolution = '1h';
  25. if (isPending) {
  26. return <LoadingIndicator />;
  27. }
  28. if (isError) {
  29. return <LoadingError />;
  30. }
  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={since}
  60. resolution={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={since}
  71. resolution={resolution}
  72. stat="events.dropped"
  73. label="Events"
  74. />
  75. </PanelBody>
  76. </Panel>
  77. </Fragment>
  78. );
  79. }