fleet/frontend/components/LogDestinationIndicator/LogDestinationIndicator.tsx
Eric Busto b6d19de0d9
Add support for publishing logs to NATS. (#36527)
**Related issue:** Resolves
[34890](https://github.com/fleetdm/fleet/issues/34890)

# Checklist for submitter
- [X] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.

## Testing
- [X] Added/updated automated tests
- [X] QA'd all new/changed functionality manually

## New Fleet configuration settings
Looking at other log destinations, I couldn't find anything relevant in
GitOps. Please let me know if I missed something, however.

## fleetd/orbit/Fleet Desktop
I've tested this on both Linux and MacOS.

---------

Co-authored-by: Rachael Shaw <r@rachael.wtf>
Co-authored-by: nulmete <nicoulmete1@gmail.com>
2026-01-06 09:10:32 -03:00

144 lines
3.7 KiB
TypeScript

import React from "react";
import classnames from "classnames";
import TooltipWrapper from "components/TooltipWrapper/TooltipWrapper";
import { DEFAULT_EMPTY_CELL_VALUE } from "utilities/constants";
import { LogDestination } from "interfaces/config";
interface ILogDestinationIndicatorProps {
logDestination: LogDestination;
webhookDestination?: string;
filesystemDestination?: string;
excludeTooltip?: boolean;
}
const generateClassTag = (rawValue: string): string => {
if (rawValue === DEFAULT_EMPTY_CELL_VALUE) {
return "indeterminate";
}
return rawValue.replace(" ", "-").toLowerCase();
};
const LogDestinationIndicator = ({
logDestination,
webhookDestination,
filesystemDestination,
excludeTooltip = false,
}: ILogDestinationIndicatorProps) => {
const classTag = generateClassTag(logDestination);
const statusClassName = classnames(
"log-destination-indicator",
`log-destination-indicator--${classTag}`,
`log-destination--${classTag}`
);
const readableLogDestination = () => {
switch (logDestination) {
case "filesystem":
return "Filesystem";
case "firehose":
return "Amazon Kinesis Data Firehose";
case "kinesis":
return "Amazon Kinesis Data Streams";
case "lambda":
return "AWS Lambda";
case "pubsub":
return "Google Cloud Pub/Sub";
case "kafka":
return "Apache Kafka";
case "nats":
return "NATS";
case "stdout":
return "Standard output (stdout)";
case "webhook":
return "Webhook";
case "":
return "Not configured";
default:
return logDestination;
}
};
const tooltipText = () => {
switch (logDestination) {
case "filesystem":
return (
<>
Each time a query runs, the data is sent to <br />
{filesystemDestination} <br />
on the server&apos;s filesystem.
</>
);
case "firehose":
return (
<>
Each time a query runs, the data is sent to <br />
Amazon Kinesis Data Firehose.
</>
);
case "kinesis":
return (
<>
Each time a query runs, the data is sent to <br />
Amazon Kinesis Data Streams.
</>
);
case "lambda":
return (
<>
Each time a query runs, the data <br />
is sent to AWS Lambda.
</>
);
case "pubsub":
return (
<>
Each time a query runs, the data is <br /> sent to Google Cloud Pub
/ Sub.
</>
);
case "kafka":
return (
<>
Each time a query runs, the data <br /> is sent to Apache Kafka.
</>
);
case "nats":
return (
<>
Each time a query runs, the data <br /> is sent to NATS.
</>
);
case "stdout":
return (
<>
Each time a query runs, the data is sent to <br />
standard output(stdout) on the Fleet server.
</>
);
case "webhook":
return (
<>
Each time a query runs, the data is sent via webhook to:{" "}
{webhookDestination}.
</>
);
case "":
return <>Please configure a log destination.</>;
default:
return (
<>
No additional information is available about this log destination.
</>
);
}
};
return excludeTooltip ? (
<>{readableLogDestination()}</>
) : (
<TooltipWrapper tipContent={tooltipText()} className={statusClassName}>
{readableLogDestination()}
</TooltipWrapper>
);
};
export default LogDestinationIndicator;