LogsConfig.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React from 'react';
  2. import { Input, InlineField, FieldSet } from '@grafana/ui';
  3. import { ElasticsearchOptions } from '../types';
  4. type Props = {
  5. value: ElasticsearchOptions;
  6. onChange: (value: ElasticsearchOptions) => void;
  7. };
  8. export const LogsConfig = (props: Props) => {
  9. const { value, onChange } = props;
  10. const changeHandler =
  11. (key: keyof ElasticsearchOptions) => (event: React.SyntheticEvent<HTMLInputElement | HTMLSelectElement>) => {
  12. onChange({
  13. ...value,
  14. [key]: event.currentTarget.value,
  15. });
  16. };
  17. return (
  18. <FieldSet label="Logs">
  19. <InlineField label="Message field name" labelWidth={22}>
  20. <Input
  21. id="es_logs-config_logMessageField"
  22. value={value.logMessageField}
  23. onChange={changeHandler('logMessageField')}
  24. placeholder="_source"
  25. width={24}
  26. />
  27. </InlineField>
  28. <InlineField label="Level field name" labelWidth={22}>
  29. <Input
  30. id="es_logs-config_logLevelField"
  31. value={value.logLevelField}
  32. onChange={changeHandler('logLevelField')}
  33. width={24}
  34. />
  35. </InlineField>
  36. </FieldSet>
  37. );
  38. };