Code Monkey home page Code Monkey logo

elasticps's Introduction

ElasticPS

A PowerShell module for managing Elasticsearch clusters.

System Requirements

  • .Net Framework 4.6+
  • PowerShell version 4+
  • Elasticsearch 2+

Build

ElasticPS was built with Visual Studio 2015 Community (it should build fine in other editions of Visual Studio). If you plan to use ElasticPS in production, don't forget to change the build configuration to Release.

Install

ElasticPS is a binary PowerShell module (ElasticPS.dll). Please refer to the PowerShell documentation to determine the best installation method for your environment.

The samples below assume that ElasticPS.dll is in the current folder, and you have the following import statement:

Import-Module ElasticPS.dll

If you have installed the module in one of the standard locations according to the PowerShell documentation, then you will just need:

Import-Module ElasticPS

Notice that .dll was dropped.

Common Usage Examples

This is very early in the devleopment process, so expect everything to change. Frequently.

Checking Cluster Health

Get-EsClusterHealth http://1.2.3.4:9200

cluster_name                     : logging
status                           : green
number_of_nodes                  : 5
number_of_data_nodes             : 5
active_primary_shards            : 0
active_shards                    : 0
relocating_shards                : 0
unassigned_shards                : 0
delayed_unassigned_shards        : 0
number_of_pending_tasks          : 0
number_of_in_flight_fetch        : 0
task_max_waiting_in_queue_millis : 0
active_shards_percent_as_number  : 100

Each of the above cluster health metrics is a property on the returned object, so if you just want to the status (for example) you can access that property directly:

# Replace the IP address with one from your own cluster
$health = Get-EsClusterHealth http://1.2.3.4:9200

switch( $health.status )
{
    "green" 
    {
        Write-Host "All is well ;)"
    }
    
    "yellow" 
    {
        Write-Host "We are not doing well folks...." 
    }

    "red" 
    {
        Write-Host "Uh oh...." 
    }

    default
    {
        Write-Host "Apparently there has been a glitch in the matrix. Again." 
    }
}

Checking Cluster State

See the Elasticsearch documentation for more information on cluster state.

# Replace the IP address with one from your own cluster
Get-EsClusterState http://1.2.3.4:9200 | fl cluster_name, version, master_node

elasticps's People

Contributors

mastry avatar

Watchers

James Cloos avatar  avatar Kostas Georgiou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.