Skip to content
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

[FEATURE] Tool development for Search Monitor Tool #1545

Closed
minalsha opened this issue Oct 24, 2023 · 2 comments
Closed

[FEATURE] Tool development for Search Monitor Tool #1545

minalsha opened this issue Oct 24, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@minalsha
Copy link

minalsha commented Oct 24, 2023

Is your feature request related to a problem?
Agent framework (#1161 ) needs tools to extend functionality. This issue propose to add search monitor and alert tools to it.

Search Alerting Monitors By Index: use this tool to search alerting monitors by index name in the OpenSearch cluster. This tool takes the index name as input

What solution would you like?

Agent framework (#1161 ) will provide a general tool framework. We can build search monitor/alerts tools with that framework.

  1. Build against the Tool interface on the agent_framework_dev branch: https://github.com/opensearch-project/ml-commons/blob/feature/agent_framework_dev/spi/src/main/java/org/opensearch/ml/common/spi/tools/Tool.java
  2. Review example tools in the Agent Framework POC commit: 1b85cff where there are 6 tools under ml-algorithms/src/main/java/org/opensearch/ml/engine/tools/. A good example is the CatIndices tool: https://github.com/opensearch-project/ml-commons/blob/feature/agent_framework_dev/ml-algorithms/src/main/java/org/opensearch/ml/engine/tools/CatIndexTool.java which shows how to use the NodeClient (IndicesAdminClient) to fetch Cluster Health statistics.
  3. Implement a similar tool using OpenSearch search functionality for Alerting Monitors by index name.

What alternatives have you considered?
N/A

Do you have any additional context?
#1161

@minalsha minalsha added enhancement New feature or request untriaged labels Oct 24, 2023
@minalsha minalsha changed the title [FEATURE] POC for Tool development for Search Monitor Tool [FEATURE] Tool development for Search Monitor Tool Oct 24, 2023
@ylwu-amzn ylwu-amzn moved this to In Progress in ml-commons projects Nov 3, 2023
@ohltyler
Copy link
Member

ohltyler commented Nov 27, 2023

Sample json body to search monitors API. Each clause corresponds to a param we can expose from the tool. The tool will generate this query.

{
    "query": {
        // list of clauses under the bool.must array
        // will omit all of below if all of triggers / monitor name pattern / monitor name / monitor enabled / input indices are null
        // if so, it is ok if the must array is empty, will just return everything
        "bool": {
            "must": [
                // triggers - will omit if nothing, else use must / must_not for triggers / no triggers, respectively
                {
                    "bool" : {
                        "must": [ // swap out must or must_not to include/exclude populated triggers or not
                            {
                                "nested": {
                                    "path": "monitor.triggers",
                                    "query": {
                                        "exists": {
                                            "field": "monitor.triggers"
                                        }
                                    }
                                } 
                            }
                        ]
                    }
                },
                // monitor name pattern / wildcard - will omit if nothing
                {
                    "wildcard": {
                        "monitor.name.keyword": {
                            "value": "*"
                        }
                    }
                },
                // explicit monitor name - will omit if nothing
                {
                   "term": {
                       "monitor.name.keyword": "ztest-monitor"
                   } 
                },
                // monitor enabled or not - will omit if nothing
                {
                    "term": {
                        "monitor.enabled": true
                    }
                },
                // monitor input indices - will omit if nothing
                {
                    "nested": {
                        "path": "monitor.inputs",
                        "query": {
                            "wildcard": {
                                "monitor.inputs.search.indices": {
                                    "value": "movies"
                                }
                            }
                        }
                    }
                }
            ]
        }
    },
    "size": 20,
    "from": 0,
    "sort": {
        "monitor.name.keyword": "asc"
    }
}

@dhrubo-os
Copy link
Collaborator

Closing this issue as we already developed this tool in skill plugin.

@github-project-automation github-project-automation bot moved this from In Progress to Done in ml-commons projects Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

4 participants