/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import React, { useState, useEffect } from "react"; import SideMenu from "components/SideMenu"; import Breadcrumb from "components/Breadcrumb"; import { useTranslation } from "react-i18next"; import { Link, useParams } from "react-router-dom"; import LoadingText from "components/LoadingText"; import HeaderPanel from "components/HeaderPanel"; import ValueWithLabel from "components/ValueWithLabel"; import { AntTab, AntTabs, TabPanel } from "components/Tab"; import { appSyncRequestQuery } from "assets/js/request"; import { getAppLogIngestion, getAppPipeline, getEKSClusterDetails, } from "graphql/queries"; import Sidecar from "./comps/Sidecar"; import { AppLogIngestion, AppPipeline, BufferType, EKSClusterLogSource, EKSDeployKind, Tag, } from "API"; import { buildKDSLink, buildS3Link, formatLocalTime } from "assets/js/utils"; import ExtLink from "components/ExtLink"; import { AmplifyConfigType } from "types"; import { AppStateProps } from "reducer/appReducer"; import { useSelector } from "react-redux"; import Tags from "./comps/Tags"; import LogConfig from "./comps/LogConfig"; import DaemonSet from "./comps/DaemonSet"; import { getParamValueByKey } from "assets/js/applog"; import AccountName from "pages/comps/account/AccountName"; interface MatchParams { eksId: string; id: string; } export interface EksDetailProps { deploymentKind: EKSDeployKind | null | undefined; bufferType: BufferType | null | undefined; enableAutoScaling: boolean; indexPrefix: string; bufferNname: string; appPipelineId: string; created: string; configId: string; logPath: string; tags: (Tag | null)[] | null | undefined; } const EksIngestionDetail: React.FC = () => { const { t } = useTranslation(); const amplifyConfig: AmplifyConfigType = useSelector( (state: AppStateProps) => state.amplifyConfig ); const { id, eksId }: MatchParams = useParams(); const [loadingData, setLoadingData] = useState(false); const [activeTab, setActiveTab] = useState(0); const [eksIngestionData, setEksIngestionData] = useState(); const [eksClusterInfo, setEksClusterInfo] = useState(); const breadCrumbList = [ { name: t("name"), link: "/" }, { name: t("menu.eksLog"), link: "/containers/eks-log", }, { name: eksClusterInfo?.eksClusterName || "", link: "/containers/eks-log/detail/" + eksId, }, { name: id }, ]; const changeTab = (event: any, newTab: number) => { console.info("newTab:", newTab); setActiveTab(newTab); }; const getEksLogIngestionById = async () => { try { setLoadingData(true); // Get Ingestion Info By ingestionId const resEksData: any = await appSyncRequestQuery(getEKSClusterDetails, { eksClusterId: eksId, }); const tmpEksData: EKSClusterLogSource = resEksData?.data?.getEKSClusterDetails; setEksClusterInfo(tmpEksData); // Get Ingestion Info By ingestionId const resIngestionData: any = await appSyncRequestQuery( getAppLogIngestion, { id: id, } ); const tmpIngestionData: AppLogIngestion = resIngestionData?.data?.getAppLogIngestion; // Get Pipeline Info by pipelineId const resPipelineData: any = await appSyncRequestQuery(getAppPipeline, { id: tmpIngestionData?.appPipelineId, }); const tmpPipelineData: AppPipeline = resPipelineData?.data?.getAppPipeline; setEksIngestionData({ deploymentKind: tmpEksData.deploymentKind, indexPrefix: tmpPipelineData.aosParams?.indexPrefix || "", bufferType: tmpPipelineData.bufferType, bufferNname: tmpPipelineData.bufferResourceName || "", enableAutoScaling: getParamValueByKey( "enableAutoScaling", tmpPipelineData.bufferParams ) === "true" ? true : false, appPipelineId: tmpPipelineData.id, configId: tmpIngestionData.confId || "", created: tmpIngestionData.createdDt || "", logPath: tmpIngestionData.logPath || "", tags: tmpIngestionData.tags, }); setLoadingData(false); } catch (error) { setLoadingData(false); console.error(error); } }; useEffect(() => { getEksLogIngestionById(); }, []); return (
{loadingData ? ( ) : (
{eksIngestionData?.indexPrefix}
<> {eksIngestionData?.bufferType === BufferType.KDS && (
{eksIngestionData?.bufferNname || "-"} {eksIngestionData?.enableAutoScaling ? t("applog:detail.autoScaling") : ""}
)} {eksIngestionData?.bufferType === BufferType.S3 && (
{eksIngestionData?.bufferNname || "-"}
)} {eksIngestionData?.bufferType === BufferType.None && (
{t("none")}
)}
{eksIngestionData?.appPipelineId}
{formatLocalTime(eksIngestionData?.created || "")}
{ changeTab(event, newTab); }} > {eksIngestionData?.deploymentKind === EKSDeployKind.Sidecar && ( )} {eksIngestionData?.deploymentKind === EKSDeployKind.DaemonSet && ( )} {eksIngestionData?.deploymentKind === EKSDeployKind.Sidecar && ( )} {eksIngestionData?.deploymentKind === EKSDeployKind.DaemonSet && ( )}
)}
); }; export default EksIngestionDetail;