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

POC Spike Fleet Management #6935

Merged
merged 22 commits into from
Aug 22, 2024
Merged

Conversation

Machi3mfl
Copy link
Member

@Machi3mfl Machi3mfl commented Aug 21, 2024

Description

This PR, creates the POC of the Fleet Management app

Closes

Spikes:

POCs

Configuration

Add index templates

PUT _index_template/fleet-agents-default
{
  "index_patterns": [
    "fleet-agents-default"
  ],
  "template": {
    "mappings": {
      "date_detection": false,
      "dynamic_templates": [
        {
          "strings_as_keyword": {
            "mapping": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "match_mapping_type": "string"
          }
        }
      ],
      "properties": {
        "agent": {
          "properties": {
            "build": {
              "properties": {
                "original": {
                  "ignore_above": 1024,
                  "type": "keyword"
                }
              }
            },
            "ephemeral_id": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "id": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "name": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "last_login": {
              "type": "date"
            },
            "version": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "groups": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "node_name": {
              "ignore_above": 1024,
              "type": "keyword"
            }
          }
        },
        "host": {
          "properties": {
            "architecture": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "checksum": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "hostname": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "ip": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "scan_time": {
              "type": "date"
            },
            "sysname": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "os": {
              "properties": {
                "full": {
                  "ignore_above": 1024,
                  "type": "keyword"
                },
                "kernel": {
                  "ignore_above": 1024,
                  "type": "keyword"
                },
                "name": {
                  "ignore_above": 1024,
                  "type": "keyword"
                },
                "platform": {
                  "ignore_above": 1024,
                  "type": "keyword"
                },
                "type": {
                  "ignore_above": 1024,
                  "type": "keyword"
                },
                "version": {
                  "ignore_above": 1024,
                  "type": "keyword"
                }
              }
            }
          }
        },
        "wazuh": {
          "properties": {
            "cluster": {
              "properties": {
                "name": {
                  "ignore_above": 1024,
                  "type": "keyword"
                }
              }
            },
            "manager": {
              "properties": {
                "name": {
                  "ignore_above": 1024,
                  "type": "keyword"
                }
              }
            },
            "node": {
              "properties": {
                "name": {
                  "ignore_above": 1024,
                  "type": "keyword"
                }
              }
            }
          }
        }
      }
    },
    "settings": {
      "index": {
        "codec": "best_compression",
        "mapping": {
          "total_fields": {
            "limit": 1000
          }
        },
        "refresh_interval": "2s"
      }
    }
  }
}

PUT _index_template/inventory-networks-default
{
  "index_patterns": [
    "inventory-networks-default"
  ],
  "template": {
    "mappings": {
      "date_detection": false,
      "dynamic_templates": [
        {
          "strings_as_keyword": {
            "mapping": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "match_mapping_type": "string"
          }
        }
      ],
      "properties": {
        "agent": {
          "properties": {
            "id": {
              "ignore_above": 1024,
              "type": "keyword"
            }
          }
        },
        "network": {
          "properties": {
            "name": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "MAC": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "state": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "mtu": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "type": {
              "ignore_above": 1024,
              "type": "keyword"
            }
          }
        },
        "wazuh": {
          "properties": {
            "cluster": {
              "properties": {
                "name": {
                  "ignore_above": 1024,
                  "type": "keyword"
                }
              }
            },
            "manager": {
              "properties": {
                "name": {
                  "ignore_above": 1024,
                  "type": "keyword"
                }
              }
            },
            "node": {
              "properties": {
                "name": {
                  "ignore_above": 1024,
                  "type": "keyword"
                }
              }
            }
          }
        }
      }
    },
    "settings": {
      "index": {
        "codec": "best_compression",
        "mapping": {
          "total_fields": {
            "limit": 1000
          }
        },
        "refresh_interval": "2s"
      }
    }
  }
}

PUT _index_template/inventory-system-default
{
  "index_patterns": [
    "inventory-system-default"
  ],
  "template": {
      "mappings": {
        "date_detection": false,
        "dynamic_templates": [
          {
            "strings_as_keyword": {
              "mapping": {
                "ignore_above": 1024,
                "type": "keyword"
              },
              "match_mapping_type": "string"
            }
          }
        ],
        "properties": {
          "agent": {
            "properties": {
              "id": {
                "ignore_above": 1024,
                "type": "keyword"
              }
            }
          },
          "host": {
            "properties": {
              "architecture": {
                "ignore_above": 1024,
                "type": "keyword"
              },
              "checksum": {
                "ignore_above": 1024,
                "type": "keyword"
              },
              "hostname": {
                "ignore_above": 1024,
                "type": "keyword"
              },
              "ip": {
                "ignore_above": 1024,
                "type": "keyword"
              },
              "scan_time": {
                "type": "date"
              },
              "sysname": {
                "ignore_above": 1024,
                "type": "keyword"
              },
              "os": {
                "properties": {
                  "full": {
                    "ignore_above": 1024,
                    "type": "keyword"
                  },
                  "kernel": {
                    "ignore_above": 1024,
                    "type": "keyword"
                  },
                  "name": {
                    "ignore_above": 1024,
                    "type": "keyword"
                  },
                  "platform": {
                    "ignore_above": 1024,
                    "type": "keyword"
                  },
                  "type": {
                    "ignore_above": 1024,
                    "type": "keyword"
                  },
                  "version": {
                    "ignore_above": 1024,
                    "type": "keyword"
                  }
                }
              }
            }
          },
          "wazuh": {
            "properties": {
              "cluster": {
                "properties": {
                  "name": {
                    "ignore_above": 1024,
                    "type": "keyword"
                  }
                }
              },
              "manager": {
                "properties": {
                  "name": {
                    "ignore_above": 1024,
                    "type": "keyword"
                  }
                }
              },
              "node": {
                "properties": {
                  "name": {
                    "ignore_above": 1024,
                    "type": "keyword"
                  }
                }
              }
            }
          }
        }
      },
      "settings": {
        "index": {
          "codec": "best_compression",
          "mapping": {
            "total_fields": {
              "limit": 1000
            }
          },
          "refresh_interval": "2s"
        }
      }
    }    
}

PUT _index_template/wazuh-fleet-groups-default
{
  "index_patterns": ["wazuh-fleet-groups-default"],
  "template": {
    "mappings": {
      "date_detection": false,
      "dynamic_templates": [
        {
          "strings_as_keyword": {
            "mapping": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "match_mapping_type": "string"
          }
        }
      ],
      "properties": {
        "id": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "name": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "agents": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "wazuh": {
          "properties": {
            "cluster": {
              "properties": {
                "name": {
                  "ignore_above": 1024,
                  "type": "keyword"
                }
              }
            },
            "manager": {
              "properties": {
                "name": {
                  "ignore_above": 1024,
                  "type": "keyword"
                }
              }
            },
            "node": {
              "properties": {
                "name": {
                  "ignore_above": 1024,
                  "type": "keyword"
                }
              }
            }
          }
        }
      }
    },
    "settings": {
      "index": {
        "codec": "best_compression",
        "mapping": {
          "total_fields": {
            "limit": 1000
          }
        },
        "refresh_interval": "2s"
      }
    }
  }
}

PUT _index_template/commands-default
{
  "index_patterns": [
    "commands-default"
  ],
  "template": {
    "mappings": {
      "dynamic": true,
      "date_detection": false,
      "dynamic_templates": [
        {
          "strings_as_keyword": {
            "mapping": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "match_mapping_type": "string"
          }
        }
      ],
      "properties": {
        "message": {
          "type": "text"
        },
        "process": {
          "properties": {
            "command_line": {
              "fields": {
                "text": {
                  "type": "text"
                }
              },
              "type": "text"
            },
            "end": {
              "type": "date"
            },
            "entity_id": {
              "ignore_above": 1024,
              "type": "keyword"
            },
            "name": {
              "fields": {
                "text": {
                  "type": "text"
                }
              },
              "ignore_above": 1024,
              "type": "keyword"
            },
            "start": {
              "type": "date"
            }
          }
        },
        "tags": {
          "ignore_above": 1024,
          "type": "keyword"
        },
        "wazuh": {
          "properties": {
            "cluster": {
              "properties": {
                "name": {
                  "ignore_above": 1024,
                  "type": "keyword"
                }
              }
            },
            "manager": {
              "properties": {
                "name": {
                  "ignore_above": 1024,
                  "type": "keyword"
                }
              }
            },
            "node": {
              "properties": {
                "name": {
                  "ignore_above": 1024,
                  "type": "keyword"
                }
              }
            }
          }
        },
        "agent": {
          "properties": {
            "id": {
              "ignore_above": 1024,
              "type": "keyword"
            }
          }
        },
        "status": {
          "type": "keyword"
        },
        "info": {
          "type": "text"
        },
        "args": {
          "type": "text"
        }
      }
    },
    "settings": {
      "index": {
        "codec": "best_compression",
        "mapping": {
          "total_fields": {
            "limit": 1000
          }
        },
        "refresh_interval": "2s"
      }
    }
  }
}

Run /scripts

  • wazuh-fleet-generator
  • wazuh-fleet-groups-generator
  • wazuh-fleet-commands-generator

Screenshot 2024-08-21 at 11 06 22

Agents section

screen-capture.webm

image

Screen.Recording.2024-08-21.at.15.35.42.mov

Groups section

Screen.Recording.2024-08-21.at.15.36.23.mov

Commands

image

Check List

  • All tests pass
    • yarn test:jest
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

@Machi3mfl Machi3mfl linked an issue Aug 21, 2024 that may be closed by this pull request
9 tasks
@asteriscos asteriscos marked this pull request as ready for review August 22, 2024 09:51
Copy link
Contributor

Wazuh Core plugin code coverage (Jest) test % values
Statements 46.02% ( 400 / 869 )
Branches 41.97% ( 157 / 374 )
Functions 44.01% ( 136 / 309 )
Lines 46.22% ( 398 / 861 )

Copy link
Contributor

Wazuh Check Updates plugin code coverage (Jest) test % values
Statements 76.44% ( 172 / 225 )
Branches 58.65% ( 61 / 104 )
Functions 61.7% ( 29 / 47 )
Lines 76.44% ( 172 / 225 )

Copy link
Contributor

Main plugin code coverage (Jest) test % values
Statements 13.6% ( 4030 / 29631 )
Branches 9.08% ( 1755 / 19325 )
Functions 13.23% ( 947 / 7155 )
Lines 13.77% ( 3928 / 28515 )

Copy link
Member

@asteriscos asteriscos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🟢

image

@asteriscos asteriscos merged commit a1fc490 into master Aug 22, 2024
5 checks passed
@asteriscos asteriscos deleted the enhancement/209-spike-fleet-management branch August 22, 2024 11:47
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.

Spike - agent comms API UX
3 participants