<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Log Insight Archives - LucD notes</title>
	<atom:link href="https://www.lucd.info/category/log-insight/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lucd.info/category/log-insight/</link>
	<description>My PowerShell ramblings</description>
	<lastBuildDate>Sat, 30 Apr 2016 19:01:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://www.lucd.info/wp-content/uploads/2018/12/cropped-120px-Tibetan_Dharmacakra-32x32.png</url>
	<title>Log Insight Archives - LucD notes</title>
	<link>https://www.lucd.info/category/log-insight/</link>
	<width>32</width>
	<height>32</height>
</image> 
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/><atom:link rel="hub" href="https://websubhub.com/hub"/>	<item>
		<title>LogInsight Module</title>
		<link>https://www.lucd.info/2016/04/29/loginsight-module/</link>
					<comments>https://www.lucd.info/2016/04/29/loginsight-module/#comments</comments>
		
		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Fri, 29 Apr 2016 15:27:20 +0000</pubDate>
				<category><![CDATA[Log Insight]]></category>
		<category><![CDATA[LogInsight]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Module]]></category>
		<guid isPermaLink="false">http://www.lucd.info/?p=5162</guid>

					<description><![CDATA[While Archimedes once said &#8220;Give me a place to stand and with a [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>While Archimedes once said &#8220;Give me a place to stand and with a lever I will move the whole world&#8221;, my personal preferred statement nowadays is &#8220;Give me an API, and I will automate it!&#8221;. And the <a href="https://github.com/lucdekens/LogInsight.git" target="_blank">LogInsight</a> module I&#8217;m announcing is another step on that path.</p>
<p><a href="https://www.lucd.info/2016/04/29/loginsight-module/pcli-loginsight/" rel="attachment wp-att-5163"><img decoding="async" class="alignnone wp-image-5163 size-medium aligncenter" src="https://lucd.info/wp-content/uploads/2016/04/pcli-loginsight-300x143.jpg" alt="pcli-loginsight" width="300" height="143" srcset="https://www.lucd.info/wp-content/uploads/2016/04/pcli-loginsight-300x143.jpg 300w, https://www.lucd.info/wp-content/uploads/2016/04/pcli-loginsight.jpg 500w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>So I was very pleased when the <a href="https://pubs.vmware.com/Release_Notes/en/LogInsight/33/log-insight-33-release-notes.html" target="_blank">Release Notes</a> of the latest <a href="https://www.vmware.com/products/vrealize-log-insight" target="_blank">Log Insight</a> version announced the availability of a <strong>Query API</strong>. On the blog of <a href="https://twitter.com/smflanders" target="_blank">Steve Flanders</a> there are several posts that go further into this new feature. Definitely worth a read to get a better understanding of what is available, and what is not (yet).</p>
<table style="height: 110px;" width="583">
<tbody>
<tr>
<td style="width: 573px;"><a href="https://sflanders.net/2016/04/11/log-insight-3-3-authentication-api/" target="_blank">Log Insight 3.3: Authentication API</a></td>
</tr>
<tr>
<td style="width: 573px;"><a href="https://sflanders.net/2016/04/20/log-insight-3-3-query-api/" target="_blank">Log Insight 3.3: Query API</a></td>
</tr>
<tr>
<td style="width: 573px;"><a href="https://sflanders.net/2016/04/26/log-insight-query-api-use-cases-basics-caveats-and-best-practices/" target="_blank">Log Insight Query API: Use Cases, Basics, Caveats, and Best Practices</a></td>
</tr>
</tbody>
</table>
<p>My <a href="https://github.com/lucdekens/LogInsight.git" target="_blank">LogInsight</a> PowerShell module makes use of these new API, and it will allow you to automate your interaction with Log Insight from within your PowerShell scripts.</p>
<p><span id="more-5162"></span></p>
<p>First a word of warning, this module is still in an early development stage, so please only use in your test environment. And definitely provide feedback in the form of issues and suggestions.</p>
<p>The use of the <a href="https://github.com/lucdekens/LogInsight.git" target="_blank">LogInsight</a> module is quite simple, there are in fact only 3 cmdlets you should use.</p>
<ol>
<li>Connect-LogInsight: this cmdlet will allow you to connect to your Log Insight server.</li>
<li>Get-LogInsightEvent: this cmdlet will allow you to retrieve events of event bins from the Log Insight server</li>
<li>Get-LogInsightConstraint: is in fact a &#8220;helper&#8221; cmdlet. It provides a more user friendly way to create the constraints for your queries</li>
</ol>
<h2>Examples</h2>
<h3>Retrieve Events</h3>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">$sConnect = @{
  Server = 'LogInsight.local.lab'
  User = 'admin'
  Password = 'VMware1!'
}
Connect-LogInsight @sConnect

$result = Get-LogInsightEvent -Event
$result.events</pre><p></p>
<p>This is the most simple way to retrieve events from the Log Insight server. Since there are no constraints, all events will be returned, within the limitations of the API. The result looks something like this.</p>
<p><a href="https://www.lucd.info/2016/04/29/loginsight-module/li-events-1/" rel="attachment wp-att-5165"><img decoding="async" class="alignnone wp-image-5165 size-medium" src="https://lucd.info/wp-content/uploads/2016/04/li-events-1-300x71.jpg" alt="li-events-1" width="300" height="71" srcset="https://www.lucd.info/wp-content/uploads/2016/04/li-events-1-300x71.jpg 300w, https://www.lucd.info/wp-content/uploads/2016/04/li-events-1-768x183.jpg 768w, https://www.lucd.info/wp-content/uploads/2016/04/li-events-1-1024x244.jpg 1024w, https://www.lucd.info/wp-content/uploads/2016/04/li-events-1.jpg 1284w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>As a side note, the objects that are returned by the <strong>Get-LogInsightEvent</strong> cmdlet, contain more information than just the event text. There is also an indication if the query actually completed within the default timeout interval.</p>
<p><a href="https://www.lucd.info/2016/04/29/loginsight-module/li-events-2/" rel="attachment wp-att-5166"><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-5166" src="https://lucd.info/wp-content/uploads/2016/04/li-events-2.jpg" alt="li-events-2" width="633" height="92" srcset="https://www.lucd.info/wp-content/uploads/2016/04/li-events-2.jpg 633w, https://www.lucd.info/wp-content/uploads/2016/04/li-events-2-300x44.jpg 300w" sizes="(max-width: 633px) 100vw, 633px" /></a></p>
<h3>Retrieve Events with Constraints</h3>
<p>On each query you can specify one or more &#8220;constraints&#8221;. In other words, you specify some conditions, and only the events that comply with these conditions will be returned.</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">Connect-LogInsight @sConnect

$constraint = Get-LogInsightConstraint -Field 'hostname' -Operator STARTS_WITH -Value 'esx1'

$result = Get-LogInsightEvent -Event -Constraint $constraint -Limit 100
$result.events</pre><p></p>
<p>To make the creation of these constraints easier, the cmdlet Get-LogInsightConstraint is available. It takes three parameters, a field, an operator and a value. In the previous code the constraint says the <strong>hostname</strong> shall start with the string &#8220;<em>esx1</em>&#8220;. The Field parameter can take any of the field names that you see in the query builder in the Log Insight console.</p>
<p><a href="https://www.lucd.info/2016/04/29/loginsight-module/li-fields/" rel="attachment wp-att-5168"><img loading="lazy" decoding="async" class="alignnone wp-image-5168 size-medium" src="https://lucd.info/wp-content/uploads/2016/04/li-fields-300x181.jpg" alt="li-fields" width="300" height="181" srcset="https://www.lucd.info/wp-content/uploads/2016/04/li-fields-300x181.jpg 300w, https://www.lucd.info/wp-content/uploads/2016/04/li-fields.jpg 528w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Notice how we also limit the returned number of events to 100 with the <strong>Limit</strong> parameter.</p>
<p>You can combine constraints, for that you just need to add all your constraints to an array.</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">Connect-LogInsight @sConnect

$constraint = @(
(Get-LogInsightConstraint -Field 'text' -Operator CONTAINS -Value 'error'),
(Get-LogInsightConstraint -Field 'hostname' -Operator STARTS_WITH -Value 'esx1')
)

$result = Get-LogInsightEvent -Constraint $constraint -Event
$result.events</pre><p></p>
<p>Which results in just one event in my test lab.</p>
<p><a href="https://www.lucd.info/2016/04/29/loginsight-module/li-events-3/" rel="attachment wp-att-5167"><img loading="lazy" decoding="async" class="alignnone wp-image-5167 size-medium" src="https://lucd.info/wp-content/uploads/2016/04/li-events-3-300x17.jpg" alt="li-events-3" width="300" height="17" srcset="https://www.lucd.info/wp-content/uploads/2016/04/li-events-3-300x17.jpg 300w, https://www.lucd.info/wp-content/uploads/2016/04/li-events-3-768x44.jpg 768w, https://www.lucd.info/wp-content/uploads/2016/04/li-events-3-1024x58.jpg 1024w, https://www.lucd.info/wp-content/uploads/2016/04/li-events-3.jpg 1246w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<h3>Retrieve Bins</h3>
<p>This feature allows running aggregate functions against fields which are returned in time-based fixed-width bins. It sounds more complex than it is.</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">Connect-LogInsight @sConnect

$constraint = Get-LogInsightConstraint -Field 'hostname' -Operator STARTS_WITH -Value 'esx1'

$result = Get-LogInsightEvent -Constraint $constraint -Aggregate
$result.bins</pre><p></p>
<p>This will return the COUNT of events in each bin, and a bin has the default width of 5000 milliseconds.</p>
<p><a href="https://www.lucd.info/2016/04/29/loginsight-module/li-bin-1/" rel="attachment wp-att-5169"><img loading="lazy" decoding="async" class="alignnone wp-image-5169 size-medium" src="https://lucd.info/wp-content/uploads/2016/04/li-bin-1-300x113.jpg" alt="li-bin-1" width="300" height="113" srcset="https://www.lucd.info/wp-content/uploads/2016/04/li-bin-1-300x113.jpg 300w, https://www.lucd.info/wp-content/uploads/2016/04/li-bin-1.jpg 373w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Note that we can use the same constraints we used before to retrieve the events.</p>
<p>There are other aggregate functions available. An interesting one is the SAMPLE function.</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">Connect-LogInsight @sConnect

$constraint = Get-LogInsightConstraint -Field 'hostname' -Operator STARTS_WITH -Value 'esx1'

$result = Get-LogInsightEvent -Constraint $constraint -Aggregate -Function SAMPLE -BinWidth 10000
$result.bins</pre><p></p>
<p>Note that we also changed the width of the bin to 10 seconds. The result looks like this</p>
<p><a href="https://www.lucd.info/2016/04/29/loginsight-module/li-bin-2/" rel="attachment wp-att-5170"><img loading="lazy" decoding="async" class="alignnone wp-image-5170 size-medium" src="https://lucd.info/wp-content/uploads/2016/04/li-bin-2-300x31.jpg" alt="li-bin-2" width="300" height="31" srcset="https://www.lucd.info/wp-content/uploads/2016/04/li-bin-2-300x31.jpg 300w, https://www.lucd.info/wp-content/uploads/2016/04/li-bin-2-768x78.jpg 768w, https://www.lucd.info/wp-content/uploads/2016/04/li-bin-2-1024x104.jpg 1024w, https://www.lucd.info/wp-content/uploads/2016/04/li-bin-2.jpg 1256w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>This <a href="https://github.com/lucdekens/LogInsight.git" target="_blank">LogInsight</a> module is still in the early stages of development. There are tons of improvements and additions that I have in mind, but I&#8217;m also counting on feedback from the Community to prioritise my work on the module. And since the module is on GitHub, feel free to pull and improve.</p>
<p>The module is available in the <a href="https://www.powershellgallery.com/" target="_blank">PSGallery</a>.</p>
<p>If you&#8217;re using WMF 5, you can do</p><pre class="urvanov-syntax-highlighter-plain-tag">Find-Module -Name LogInsight | Install-Module -Scope CurrentUser -Force -Confirm:$false</pre><p></p>
<p>Enjoy!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lucd.info/2016/04/29/loginsight-module/feed/</wfw:commentRss>
			<slash:comments>15</slash:comments>
		
		
			</item>
	</channel>
</rss>
