Skip to content

Commit

Permalink
feat: prometheus working integration. prompt WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nherment committed Jan 29, 2025
1 parent e5a0fb4 commit 768e39a
Show file tree
Hide file tree
Showing 5 changed files with 335 additions and 222 deletions.
7 changes: 5 additions & 2 deletions holmes/plugins/toolsets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import List, Optional

from holmes.core.supabase_dal import SupabaseDal
from holmes.plugins.toolsets.datetime import DatetimeToolset
from holmes.plugins.toolsets.findings import FindingsToolset
from holmes.plugins.toolsets.internet import InternetToolset
from pydantic import BaseModel
Expand All @@ -13,6 +14,7 @@
from pydantic import BaseModel
from typing import Optional
import yaml
from holmes.plugins.toolsets.prometheus import PrometheusToolset

THIS_DIR = os.path.abspath(os.path.dirname(__file__))

Expand All @@ -31,7 +33,7 @@ def load_toolsets_from_file(path: str, silent_fail: bool = False) -> List[YAMLTo
toolset = YAMLToolset(**config, name=name)
toolset.set_path(path)
file_toolsets.append(YAMLToolset(**config, name=name))
except Exception as e:
except Exception:
if not silent_fail:
logging.error(f"Error happened while loading {name} toolset from {path}",
exc_info=True)
Expand All @@ -41,7 +43,8 @@ def load_toolsets_from_file(path: str, silent_fail: bool = False) -> List[YAMLTo

def load_python_toolsets(dal:Optional[SupabaseDal]) -> List[Toolset]:
logging.debug("loading python toolsets")
return [InternetToolset(), FindingsToolset(dal)]

return [InternetToolset(), FindingsToolset(dal), PrometheusToolset(None), DatetimeToolset()]


def load_builtin_toolsets(dal:Optional[SupabaseDal] = None) -> List[Toolset]:
Expand Down
33 changes: 33 additions & 0 deletions holmes/plugins/toolsets/datetime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from holmes.core.tools import ToolsetTag
from typing import Dict
from holmes.core.tools import Tool, Toolset
from datetime import datetime

class CurrentTime(Tool):
def __init__(self):
super().__init__(
name="get_current_time",
description="Return current time information. Useful to build queries that require a time information",
parameters={
},
)

def invoke(self, params: Dict) -> str:
now = datetime.utcnow()
return f"The current UTC date and time are {now}. The current UTC timestamp in seconds is {int(now.timestamp())}."

def get_parameterized_one_liner(self, params) -> str:
return "fetched current time"


class DatetimeToolset(Toolset):
def __init__(self):
super().__init__(
name="datetime",
description="Current date and time information",
icon_url="https://platform.robusta.dev/demos/internet-access.svg",
prerequisites=[
],
tools=[CurrentTime()],
tags=[ToolsetTag.CORE]
)
Loading

0 comments on commit 768e39a

Please sign in to comment.