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

Implement timeseries index model to command-manager plugin #153

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

QU3B1M
Copy link
Member

@QU3B1M QU3B1M commented Nov 28, 2024

Description

Implement timestamp and deliveryTimestamp attributes to the command-manager's Document model, the attributes are mapped to the @timestamp and delivery_timestamp fields corresponding to each case.

  • timestamp: Auto-fill with current date-time timestamp
  • deliveryTimestamp: Auto-fill with timestamp + timeout

Updated command index template on both plugins' resources.

Functionality validation

Command generated using the _plugins/_command_manager/commands endpoint

POST request detail
curl -s -k -u "admin:admin" -X POST "http://127.0.0.1:9200/_plugins/_command_manager/commands" -H 'accept: */*' -H 'Content-Type: application/json' -d "{ 
  \"source\": \"Engine\",
  \"user\": \"TestUser\",
  \"target\": {
    \"id\": \"TestTarget\",
    \"type\": \"agent\"
  },
  \"action\": {
    \"name\": \"restart\",
    \"args\": [
      \"/test/path/fake/args\"
    ],
    \"version\": \"v4\"
  },
  \"timeout\": 30
}"
{
    "took": 32,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 1,
            "relation": "eq"
        },
        "max_score": 1.0,
        "hits": [
            {
                "_index": ".commands",
                "_id": "fZuAdJMBy-t6tcAPACYT",
                "_score": 1.0,
                "_source": {
                    "agent": {
                        "groups": [
                            "groups000"
                        ]
                    },
                    "command": {
                        "source": "Engine",
                        "user": "TestUser",
                        "target": {
                            "type": "agent",
                            "id": "TestTarget"
                        },
                        "action": {
                            "name": "restart",
                            "args": [
                                "/test/path/fake/args"
                            ],
                            "version": "v4"
                        },
                        "timeout": 30,
                        "status": "PENDING",
                        "order_id": "fJuAdJMBy-t6tcAPACYT",
                        "request_id": "e5uAdJMBy-t6tcAPACYS"
                    },
                    "@timestamp": 1732826365971,
                    "delivery_timestamp": 1732826395971
                }
            }
        ]
    }
}

Issues Resolved

Resolves wazuh/wazuh-indexer#565

Add @timestamp and delivery_timestamp fields
@QU3B1M QU3B1M self-assigned this Nov 28, 2024
Add getter function for the Command attrbiture timeout

Use native System.currentTimeMillis() to get current timestamp
Move delivery_timestamp to top-level
…ocument model

Add missing 'this' on timeout getter
@QU3B1M QU3B1M marked this pull request as ready for review November 29, 2024 19:56
@QU3B1M QU3B1M requested a review from a team as a code owner November 29, 2024 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Command manager timeseries index model
2 participants