-
Notifications
You must be signed in to change notification settings - Fork 68
Feature/opensearch victorops connectors #410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Apok21
wants to merge
5
commits into
Arvo-AI:main
Choose a base branch
from
Apok21:feature/opensearch-victorops-connectors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
889c76e
feat: add OpenSearch and Splunk On-Call (VictorOps) connectors
Apok21 e2a3f45
revert: remove unrelated Atlassian Cloud changes from connector PR
Apok21 669406a
fix: address CodeRabbit and SonarCloud review feedback on OpenSearch/…
Apok21 870029d
fix: resolve SonarCloud code quality issues in OpenSearch/VictorOps c…
Apok21 d458f91
fix: address follow-up review feedback on OpenSearch/VictorOps connec…
Apok21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { NextRequest } from 'next/server'; | ||
| import { forwardRequest } from '@/lib/backend-proxy'; | ||
|
|
||
| export async function GET( | ||
| request: NextRequest, | ||
| { params }: { params: Promise<{ path: string[] }> }, | ||
| ) { | ||
| const { path } = await params; | ||
| return forwardRequest(request, 'GET', `/opensearch/${path.join('/')}`, 'opensearch'); | ||
| } | ||
|
|
||
| export async function POST( | ||
| request: NextRequest, | ||
| { params }: { params: Promise<{ path: string[] }> }, | ||
| ) { | ||
| const { path } = await params; | ||
| return forwardRequest(request, 'POST', `/opensearch/${path.join('/')}`, 'opensearch'); | ||
| } | ||
|
|
||
| export async function DELETE( | ||
| request: NextRequest, | ||
| { params }: { params: Promise<{ path: string[] }> }, | ||
| ) { | ||
| const { path } = await params; | ||
| return forwardRequest(request, 'DELETE', `/opensearch/${path.join('/')}`, 'opensearch'); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { NextRequest } from 'next/server'; | ||
| import { forwardRequest } from '@/lib/backend-proxy'; | ||
|
|
||
| export async function GET(request: NextRequest) { | ||
| return forwardRequest(request, 'GET', '/victorops', 'victorops'); | ||
| } | ||
|
|
||
| export async function POST(request: NextRequest) { | ||
| return forwardRequest(request, 'POST', '/victorops', 'victorops'); | ||
| } | ||
|
|
||
| export async function DELETE(request: NextRequest) { | ||
| return forwardRequest(request, 'DELETE', '/victorops', 'victorops'); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { NextRequest } from 'next/server'; | ||
| import { forwardRequest } from '@/lib/backend-proxy'; | ||
|
|
||
| export async function GET(request: NextRequest) { | ||
| return forwardRequest(request, 'GET', '/victorops/webhook-url', 'victorops-webhook-url'); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,294 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect, useState } from "react"; | ||
| import { useToast } from "@/hooks/use-toast"; | ||
| import { openSearchService, OpenSearchStatus } from "@/lib/services/opensearch"; | ||
| import { Button } from "@/components/ui/button"; | ||
| import { Input } from "@/components/ui/input"; | ||
| import { Label } from "@/components/ui/label"; | ||
| import { Card, CardContent, CardDescription, CardHeader, CardTitle, CardFooter } from "@/components/ui/card"; | ||
| import { Loader2, CheckCircle, ExternalLink, Database } from "lucide-react"; | ||
| import ConnectorAuthGuard from "@/components/connectors/ConnectorAuthGuard"; | ||
|
|
||
| const CACHE_KEY = "opensearch_connection_status"; | ||
|
|
||
| export default function OpenSearchAuthPage() { | ||
| const { toast } = useToast(); | ||
| const [endpoint, setEndpoint] = useState(""); | ||
| const [username, setUsername] = useState(""); | ||
| const [password, setPassword] = useState(""); | ||
| const [indexPattern, setIndexPattern] = useState("*"); | ||
| const [status, setStatus] = useState<OpenSearchStatus | null>(null); | ||
| const [loading, setLoading] = useState(false); | ||
| const [isCheckingStatus, setIsCheckingStatus] = useState(true); | ||
|
|
||
| const loadStatus = async () => { | ||
| try { | ||
| if (globalThis.window !== undefined) { | ||
| const cached = localStorage.getItem(CACHE_KEY); | ||
| if (cached) { | ||
| const parsed = JSON.parse(cached); | ||
| setStatus(parsed); | ||
| if (parsed?.connected) setEndpoint(parsed.endpoint ?? ""); | ||
| } | ||
| } | ||
| const result = await openSearchService.getStatus(); | ||
| if (result !== null) { | ||
| setStatus(result); | ||
| if (globalThis.window !== undefined) { | ||
| localStorage.setItem(CACHE_KEY, JSON.stringify({ connected: result.connected })); | ||
| if (result.connected) setEndpoint(result.endpoint ?? ""); | ||
| } | ||
| } | ||
| } catch (err) { | ||
| console.error("[OpenSearch] Failed to load status", err); | ||
| } finally { | ||
| setIsCheckingStatus(false); | ||
| } | ||
| }; | ||
|
|
||
| useEffect(() => { loadStatus(); }, []); | ||
|
|
||
| const handleConnect = async (e: React.FormEvent<HTMLFormElement>) => { | ||
| e.preventDefault(); | ||
| setLoading(true); | ||
| try { | ||
| const result = await openSearchService.connect({ | ||
| endpoint, | ||
| username, | ||
| password, | ||
| indexPattern: indexPattern || "*", | ||
| }); | ||
| setStatus(result); | ||
| if (globalThis.window !== undefined) { | ||
| localStorage.setItem(CACHE_KEY, JSON.stringify({ connected: result.connected })); | ||
| localStorage.setItem("isOpenSearchConnected", result.connected ? "true" : "false"); | ||
| globalThis.dispatchEvent(new Event("openSearchStateChanged")); | ||
| globalThis.dispatchEvent(new Event("providerStateChanged")); | ||
| } | ||
| toast({ title: "OpenSearch connected", description: `Cluster: ${result.clusterName ?? endpoint}` }); | ||
| setPassword(""); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } catch (err: unknown) { | ||
| const msg = err instanceof Error ? err.message : "Connection failed"; | ||
| toast({ title: "Failed to connect", description: msg, variant: "destructive" }); | ||
| } finally { | ||
| setLoading(false); | ||
| } | ||
| }; | ||
|
|
||
| const handleDisconnect = async () => { | ||
| setLoading(true); | ||
| try { | ||
| const response = await fetch("/api/opensearch/disconnect", { | ||
| method: "DELETE", | ||
| credentials: "include", | ||
| }); | ||
| if (response.ok || response.status === 204) { | ||
| setStatus({ connected: false }); | ||
| setEndpoint(""); | ||
| setUsername(""); | ||
| setPassword(""); | ||
| if (globalThis.window !== undefined) { | ||
| localStorage.removeItem(CACHE_KEY); | ||
| localStorage.removeItem("isOpenSearchConnected"); | ||
| globalThis.dispatchEvent(new Event("openSearchStateChanged")); | ||
| globalThis.dispatchEvent(new Event("providerStateChanged")); | ||
| } | ||
| toast({ title: "OpenSearch disconnected" }); | ||
| } else { | ||
| throw new Error("Failed to disconnect"); | ||
| } | ||
| } catch (err: unknown) { | ||
| toast({ title: "Failed to disconnect", description: err instanceof Error ? err.message : "Unknown error", variant: "destructive" }); | ||
| } finally { | ||
| setLoading(false); | ||
| } | ||
| }; | ||
|
|
||
| if (isCheckingStatus) { | ||
| return ( | ||
| <ConnectorAuthGuard connectorName="OpenSearch"> | ||
| <div className="container mx-auto py-8 px-4 max-w-2xl"> | ||
| <div className="mb-6"> | ||
| <h1 className="text-3xl font-bold">OpenSearch Integration</h1> | ||
| <p className="text-muted-foreground mt-1">Connect your OpenSearch cluster for log search during RCA</p> | ||
| </div> | ||
| <Card> | ||
| <CardContent className="flex items-center justify-center py-12"> | ||
| <Loader2 className="h-8 w-8 animate-spin text-muted-foreground" /> | ||
| </CardContent> | ||
| </Card> | ||
| </div> | ||
| </ConnectorAuthGuard> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <ConnectorAuthGuard connectorName="OpenSearch"> | ||
| <div className="container mx-auto py-8 px-4 max-w-2xl space-y-6"> | ||
| <div className="flex items-center gap-4"> | ||
| <div className="h-14 w-14 rounded-xl bg-white border flex items-center justify-center p-2.5 shadow-sm"> | ||
| <Database className="h-8 w-8 text-[#005EB8]" /> | ||
| </div> | ||
| <div> | ||
| <h1 className="text-3xl font-bold">OpenSearch</h1> | ||
| <p className="text-muted-foreground mt-0.5">Search logs and traces during incident RCA</p> | ||
| </div> | ||
| </div> | ||
|
|
||
| {status?.connected ? ( | ||
| <Card className="border-[#005EB8]/30 bg-[#005EB8]/[0.03]"> | ||
| <CardHeader className="pb-3"> | ||
| <div className="flex items-center justify-between"> | ||
| <div className="flex items-center gap-2.5"> | ||
| <div className="h-8 w-8 rounded-full bg-[#005EB8]/10 flex items-center justify-center"> | ||
| <CheckCircle className="h-4 w-4 text-[#005EB8]" /> | ||
| </div> | ||
| <div> | ||
| <CardTitle className="text-base">Connected</CardTitle> | ||
| <CardDescription className="text-xs">{status.endpoint}</CardDescription> | ||
| </div> | ||
| </div> | ||
| <span className="text-[10px] font-semibold uppercase tracking-wider text-[#005EB8] bg-[#005EB8]/10 px-2 py-1 rounded-full"> | ||
| Basic Auth | ||
| </span> | ||
| </div> | ||
| </CardHeader> | ||
| <CardContent className="pt-0 pb-3"> | ||
| <div className="grid grid-cols-2 gap-3 text-sm"> | ||
| {status.clusterName && ( | ||
| <div> | ||
| <p className="text-xs text-muted-foreground">Cluster</p> | ||
| <p className="font-medium">{status.clusterName}</p> | ||
| </div> | ||
| )} | ||
| {status.version && ( | ||
| <div> | ||
| <p className="text-xs text-muted-foreground">Version</p> | ||
| <p className="font-medium">{status.version}</p> | ||
| </div> | ||
| )} | ||
| {status.indexPattern && ( | ||
| <div> | ||
| <p className="text-xs text-muted-foreground">Index Pattern</p> | ||
| <p className="font-mono text-xs">{status.indexPattern}</p> | ||
| </div> | ||
| )} | ||
| </div> | ||
| </CardContent> | ||
| <CardFooter className="pt-0"> | ||
| <Button | ||
| variant="ghost" | ||
| size="sm" | ||
| className="text-muted-foreground hover:text-destructive" | ||
| onClick={handleDisconnect} | ||
| disabled={loading} | ||
| > | ||
| {loading ? <Loader2 className="mr-2 h-3.5 w-3.5 animate-spin" /> : null} | ||
| Disconnect | ||
| </Button> | ||
| </CardFooter> | ||
| </Card> | ||
| ) : ( | ||
| <Card> | ||
| <CardHeader> | ||
| <CardTitle>Connect to OpenSearch</CardTitle> | ||
| <CardDescription> | ||
| Enter your cluster endpoint and credentials. Aurora uses Basic authentication. | ||
| </CardDescription> | ||
| </CardHeader> | ||
| <CardContent> | ||
| <form onSubmit={handleConnect} className="space-y-4"> | ||
| <div className="space-y-1.5"> | ||
| <Label htmlFor="endpoint">Cluster Endpoint</Label> | ||
| <Input | ||
| id="endpoint" | ||
| type="url" | ||
| placeholder="https://centrallogserver.monotype.com" | ||
| value={endpoint} | ||
| onChange={(e) => setEndpoint(e.target.value)} | ||
| required | ||
| /> | ||
| <p className="text-xs text-muted-foreground">Include the full URL with port if non-standard</p> | ||
| </div> | ||
|
|
||
| <div className="grid grid-cols-2 gap-3"> | ||
| <div className="space-y-1.5"> | ||
| <Label htmlFor="username">Username</Label> | ||
| <Input | ||
| id="username" | ||
| type="text" | ||
| placeholder="SRE" | ||
| value={username} | ||
| onChange={(e) => setUsername(e.target.value)} | ||
| required | ||
| /> | ||
| </div> | ||
| <div className="space-y-1.5"> | ||
| <Label htmlFor="password">Password</Label> | ||
| <Input | ||
| id="password" | ||
| type="password" | ||
| placeholder="••••••••" | ||
| value={password} | ||
| onChange={(e) => setPassword(e.target.value)} | ||
| required | ||
| /> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="space-y-1.5"> | ||
| <Label htmlFor="indexPattern">Index Pattern</Label> | ||
| <Input | ||
| id="indexPattern" | ||
| type="text" | ||
| placeholder="*" | ||
| value={indexPattern} | ||
| onChange={(e) => setIndexPattern(e.target.value)} | ||
| /> | ||
| <p className="text-xs text-muted-foreground"> | ||
| Wildcards supported, e.g. <code className="bg-muted px-1 rounded">logs-*</code> or <code className="bg-muted px-1 rounded">*</code> for all | ||
| </p> | ||
| </div> | ||
|
|
||
| <div className="bg-muted/50 rounded-lg p-3 text-xs text-muted-foreground space-y-1"> | ||
| <p className="font-medium text-foreground">What Aurora uses this for:</p> | ||
| <ul className="list-disc list-inside space-y-0.5"> | ||
| <li>Search logs by keyword or service name during RCA</li> | ||
| <li>Find error traces within the incident time window</li> | ||
| <li>Correlate log patterns with triggered alerts</li> | ||
| </ul> | ||
| </div> | ||
|
|
||
| <Button | ||
| type="submit" | ||
| className="w-full bg-[#005EB8] hover:bg-[#004d99] text-white" | ||
| disabled={loading || !endpoint || !username || !password} | ||
| > | ||
| {loading ? <Loader2 className="mr-2 h-4 w-4 animate-spin" /> : null} | ||
| Connect to OpenSearch | ||
| </Button> | ||
| </form> | ||
| </CardContent> | ||
| </Card> | ||
| )} | ||
|
|
||
| <Card className="border-dashed"> | ||
| <CardHeader className="pb-2"> | ||
| <CardTitle className="text-sm">OpenSearch REST API Docs</CardTitle> | ||
| </CardHeader> | ||
| <CardContent className="pt-0"> | ||
| <a | ||
| href="https://opensearch.org/docs/latest/api-reference/" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| className="inline-flex items-center gap-1.5 text-xs text-[#005EB8] hover:underline" | ||
| > | ||
| View OpenSearch API reference <ExternalLink className="h-3 w-3" /> | ||
| </a> | ||
| </CardContent> | ||
| </Card> | ||
| </div> | ||
| </ConnectorAuthGuard> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.