<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>ashish.one</title>
    <link>https://ashish.one/</link>
    <description>Recent content on ashish.one</description>
    <image>
      <title>ashish.one</title>
      <url>https://ashish.one/img/speaker-pic/ashish.png</url>
      <link>https://ashish.one/img/speaker-pic/ashish.png</link>
    </image>
    <generator>Hugo -- 0.136.4</generator>
    <language>en-us</language>
    <lastBuildDate>Sat, 10 Jan 2026 02:07:01 +0530</lastBuildDate>
    <atom:link href="https://ashish.one/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Streamlining Vector Search with private model: Unifying Embedding Models with LiteLLM and Elasticsearch</title>
      <link>https://ashish.one/blogs/vector-search-with-litellm-elasticsearch/</link>
      <pubDate>Thu, 08 Jan 2026 21:21:21 +0530</pubDate>
      <guid>https://ashish.one/blogs/vector-search-with-litellm-elasticsearch/</guid>
      <description>Learn how to host an embedding model using LiteLLM proxy on Docker and consume it directly from Elasticsearch for seamless vector search.</description>
      <content:encoded><![CDATA[<p>In the rapidly evolving landscape of AI, managing the &ldquo;plumbing&rdquo; between your embedding models and your search engine is often a challenge. Developers frequently struggle with switching providers, managing API keys, and maintaining consistent API specifications.</p>
<p><strong>LiteLLM</strong> solves the model management problem by acting as a universal proxy, while <strong>Elasticsearch</strong> delivers high-performance Vector Search. By combining them, you can build a search architecture that is both flexible and powerful.</p>
<p>In this guide, we will walk through hosting an OpenAI-compatible embedding model using LiteLLM on Docker and consuming it directly from Elasticsearch to perform seamless vector search.</p>
<h3 id="prerequisites">Prerequisites</h3>
<ul>
<li><strong>OS:</strong> Ubuntu 24.04.3 LTS (or similar Linux environment)</li>
<li><strong>Docker:</strong> Ensure Docker is installed and running.</li>
<li><strong>Elasticsearch:</strong> An Elastic Cloud instance or a self-managed cluster.</li>
</ul>
<hr>
<h3 id="step-1-configure-and-run-litellm">Step 1: Configure and Run LiteLLM</h3>
<p>First, we need to configure LiteLLM. This tool will act as our gateway, proxying requests to various models (like GPT-4 or specific embedding models) while presenting a unified OpenAI-compatible API to the outside world.</p>
<p><strong>1. Create the <code>config.yaml</code> file:</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-yaml" data-lang="yaml"><span style="display:flex;"><span><span style="color:#f92672">model_list</span>:
</span></span><span style="display:flex;"><span>  - <span style="color:#f92672">model_name</span>: <span style="color:#ae81ff">gpt-4o</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">litellm_params</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">model</span>: <span style="color:#ae81ff">openai/gpt-4o</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">api_key</span>: <span style="color:#ae81ff">os.environ/OPENAI_API_KEY</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  - <span style="color:#f92672">model_name</span>: <span style="color:#ae81ff">gpt-3.5-turbo</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">litellm_params</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">model</span>: <span style="color:#ae81ff">openai/gpt-3.5-turbo</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">api_key</span>: <span style="color:#ae81ff">os.environ/OPENAI_API_KEY</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  - <span style="color:#f92672">model_name</span>: <span style="color:#ae81ff">text-embedding-3-small</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">litellm_params</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">model</span>: <span style="color:#ae81ff">openai/text-embedding-3-small</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">api_key</span>: <span style="color:#ae81ff">os.environ/OPENAI_API_KEY</span>
</span></span></code></pre></div><p><strong>2. Run LiteLLM with Docker:</strong></p>
<p>We will run the container with the config mounted. We also define a <code>LITELLM_MASTER_KEY</code> (<code>sk-my-admin-key-123</code>), which will serve as the static API key for our internal services to authenticate against this proxy.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>docker run -d <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  -p 4000:4000 <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  -v <span style="color:#66d9ef">$(</span>pwd<span style="color:#66d9ef">)</span>/config.yaml:/app/config.yaml <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  -e OPENAI_API_KEY<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;enter your openai api key&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  -e LITELLM_MASTER_KEY<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;sk-my-admin-key-123&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  docker.litellm.ai/berriai/litellm:main-latest <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  --config /app/config.yaml --detailed_debug
</span></span></code></pre></div><hr>
<h3 id="step-2-verify-the-proxy">Step 2: Verify the Proxy</h3>
<p>let’s ensure our LiteLLM proxy is correctly handling requests.</p>
<p><strong>Test Chat Completion:</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>curl http://0.0.0.0:4000/v1/chat/completions <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  -H <span style="color:#e6db74">&#34;Content-Type: application/json&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  -H <span style="color:#e6db74">&#34;Authorization: Bearer sk-my-admin-key-123&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  -d <span style="color:#e6db74">&#39;{
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;model&#34;: &#34;gpt-4o&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;messages&#34;: [
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      { &#34;role&#34;: &#34;user&#34;, &#34;content&#34;: &#34;Hello from LiteLLM Docker!&#34; }
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    ]
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  }&#39;</span>
</span></span></code></pre></div><p><strong>Test Embedding Generation:</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>curl http://0.0.0.0:4000/v1/embeddings <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  -H <span style="color:#e6db74">&#34;Content-Type: application/json&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  -H <span style="color:#e6db74">&#34;Authorization: Bearer sk-my-admin-key-123&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  -d <span style="color:#e6db74">&#39;{
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;model&#34;: &#34;text-embedding-3-small&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;input&#34;: &#34;LiteLLM makes proxying easy.&#34;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  }&#39;</span>
</span></span></code></pre></div><hr>
<h3 id="step-3-configure-elasticsearch-inference">Step 3: Configure Elasticsearch Inference</h3>
<p>Now we connect the two pieces. Let&rsquo;s <a href="https://www.elastic.co/docs/deploy-manage/deploy/elastic-cloud/create-an-elastic-cloud-hosted-deployment">create elatic deployment</a> instance from Elastic cloud.</p>
<p>Since LiteLLM provides an OpenAI-compatible interface, we can use the standard OpenAI inference in Elasticsearch but point it to our custom LiteLLM URL.</p>
<p><em>For more details on configuring these connectors, refer to the <a href="https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-openai">API doc</a></em></p>
<p><strong>Create the Inference Endpoint</strong></p>
<p>Run the following in your Kibana Dev Tools. Note that the <code>url</code> points to our LiteLLM endpoint and the <code>api_key</code> matches our LiteLLM master key.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">PUT</span> <span style="color:#960050;background-color:#1e0010">_inference/text_embedding/litellm-embeddings</span>
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>   <span style="color:#f92672">&#34;service&#34;</span>: <span style="color:#e6db74">&#34;openai&#34;</span>,
</span></span><span style="display:flex;"><span>   <span style="color:#f92672">&#34;service_settings&#34;</span>: {
</span></span><span style="display:flex;"><span>       <span style="color:#f92672">&#34;api_key&#34;</span>: <span style="color:#e6db74">&#34;sk-my-admin-key-123&#34;</span>,
</span></span><span style="display:flex;"><span>       <span style="color:#f92672">&#34;model_id&#34;</span>: <span style="color:#e6db74">&#34;text-embedding-3-small&#34;</span>,
</span></span><span style="display:flex;"><span>       <span style="color:#f92672">&#34;url&#34;</span>: <span style="color:#e6db74">&#34;http://litellm_endpoint:4000/v1/embeddings&#34;</span>,
</span></span><span style="display:flex;"><span>       <span style="color:#f92672">&#34;dimensions&#34;</span>: <span style="color:#ae81ff">128</span>
</span></span><span style="display:flex;"><span>   }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><em>Output</em></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;inference_id&#34;</span>: <span style="color:#e6db74">&#34;litellm-embeddings&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;task_type&#34;</span>: <span style="color:#e6db74">&#34;text_embedding&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;service&#34;</span>: <span style="color:#e6db74">&#34;openai&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;service_settings&#34;</span>: {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;model_id&#34;</span>: <span style="color:#e6db74">&#34;text-embedding-3-small&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;url&#34;</span>: <span style="color:#e6db74">&#34;http://litellm_endpoint:4000/v1/embeddings&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;similarity&#34;</span>: <span style="color:#e6db74">&#34;dot_product&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;dimensions&#34;</span>: <span style="color:#ae81ff">128</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;rate_limit&#34;</span>: {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;requests_per_minute&#34;</span>: <span style="color:#ae81ff">3000</span>
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;chunking_settings&#34;</span>: {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;strategy&#34;</span>: <span style="color:#e6db74">&#34;sentence&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;max_chunk_size&#34;</span>: <span style="color:#ae81ff">250</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;sentence_overlap&#34;</span>: <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><strong>Test the Inference Endpoint</strong></p>
<p>Let&rsquo;s verify that Elasticsearch can generate embeddings via LiteLLM:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">POST</span> <span style="color:#960050;background-color:#1e0010">_inference/text_embedding/litellm-embeddings</span>
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span> <span style="color:#f92672">&#34;input&#34;</span>: <span style="color:#e6db74">&#34;The sky above the port was the color of television tuned to a dead channel.&#34;</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><strong>Output:</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;text_embedding&#34;</span>: [
</span></span><span style="display:flex;"><span>    {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;embedding&#34;</span>: [
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.02372423</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.016345346</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.269933</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.038996283</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.06547082</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.04299877</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.059388835</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.13049445</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.019900626</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.09131928</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.024954043</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.08608698</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.072268344</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.09623853</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.06260871</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.0264969</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.21161744</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.00086855615</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.2389864</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.07410188</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.00018866465</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.0704348</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.08724971</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.14078017</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.121192575</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.011660873</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.07177641</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.070211194</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.01770932</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.13067332</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.02551305</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.16734414</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.0144000035</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.033562742</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.12226587</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.097311825</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.08868077</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.011236028</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.08631058</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.13541369</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.007585716</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.08742859</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.19337147</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.072447225</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.025155285</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.07025592</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.0071552815</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.03591057</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.118509345</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.028598765</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.094628595</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.051115543</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.03497144</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.053888213</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.046196286</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.091945365</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.013449693</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.025759013</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.13764973</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.046554048</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.08841244</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.05460374</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.025826093</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.030611187</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.012197519</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.1722634</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.02372423</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.0021340067</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.025222367</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.06158014</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.09740127</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.010352798</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.05701865</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.06381617</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.0127341645</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.042149078</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.034144107</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.012432301</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.1711901</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.13112053</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.0789317</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.12879506</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.14677271</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.02915777</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.0157528</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.007390064</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.04659877</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.10473543</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.04152299</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.16662861</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.017060874</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.12333916</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.06256399</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.09167704</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.023120502</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.03872796</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.17852427</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.020314291</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.023232304</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.050578896</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.05983604</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.020470813</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.14417891</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.0002360055</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.0051400634</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.07334163</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.12655903</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.0008245344</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.057644736</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.067080766</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.02989566</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.04223852</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.14838265</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.1329988</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.009531058</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.038638517</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.08076524</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.0014939444</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.24846715</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.012711804</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.003342858</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.014411184</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.077232316</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.033629823</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.082598776</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">-0.020850938</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.08376151</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0.12772177</span>
</span></span><span style="display:flex;"><span>      ]
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>  ]
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><hr>
<h3 id="step-4-end-to-end-vector-search">Step 4: End-to-End Vector Search</h3>
<p>Now that the pipeline is ready, we can perform <strong>Semantic Search</strong>. We will use the (semantic_text)[https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/semantic-text] field type, which abstracts the embedding generation process—Elasticsearch calls LiteLLM automatically during data ingestion and query time.</p>
<p><strong>1. Create the Index</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">PUT</span> <span style="color:#960050;background-color:#1e0010">/litellm-test-index</span>
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span> <span style="color:#f92672">&#34;mappings&#34;</span>: {
</span></span><span style="display:flex;"><span>   <span style="color:#f92672">&#34;properties&#34;</span>: {
</span></span><span style="display:flex;"><span>     <span style="color:#f92672">&#34;content&#34;</span>: {
</span></span><span style="display:flex;"><span>       <span style="color:#f92672">&#34;type&#34;</span>: <span style="color:#e6db74">&#34;semantic_text&#34;</span>,
</span></span><span style="display:flex;"><span>       <span style="color:#f92672">&#34;inference_id&#34;</span>: <span style="color:#e6db74">&#34;litellm-embeddings&#34;</span>
</span></span><span style="display:flex;"><span>     },
</span></span><span style="display:flex;"><span>     <span style="color:#f92672">&#34;category&#34;</span>: {
</span></span><span style="display:flex;"><span>       <span style="color:#f92672">&#34;type&#34;</span>: <span style="color:#e6db74">&#34;keyword&#34;</span>
</span></span><span style="display:flex;"><span>     }
</span></span><span style="display:flex;"><span>   }
</span></span><span style="display:flex;"><span> }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><strong>2. Ingest Data</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">POST</span> <span style="color:#960050;background-color:#1e0010">/litellm-test-index/_bulk</span>
</span></span><span style="display:flex;"><span>{ <span style="color:#f92672">&#34;index&#34;</span>: {} }
</span></span><span style="display:flex;"><span>{ <span style="color:#f92672">&#34;content&#34;</span>: <span style="color:#e6db74">&#34;The quick brown fox jumps over the lazy dog.&#34;</span>, <span style="color:#f92672">&#34;category&#34;</span>: <span style="color:#e6db74">&#34;animals&#34;</span> }
</span></span><span style="display:flex;"><span>{ <span style="color:#f92672">&#34;index&#34;</span>: {} }
</span></span><span style="display:flex;"><span>{ <span style="color:#f92672">&#34;content&#34;</span>: <span style="color:#e6db74">&#34;Artificial intelligence is transforming software development.&#34;</span>, <span style="color:#f92672">&#34;category&#34;</span>: <span style="color:#e6db74">&#34;tech&#34;</span> }
</span></span><span style="display:flex;"><span>{ <span style="color:#f92672">&#34;index&#34;</span>: {} }
</span></span><span style="display:flex;"><span>{ <span style="color:#f92672">&#34;content&#34;</span>: <span style="color:#e6db74">&#34;Docker containers make deployment consistent and easy.&#34;</span>, <span style="color:#f92672">&#34;category&#34;</span>: <span style="color:#e6db74">&#34;tech&#34;</span> }
</span></span></code></pre></div><p><strong>3. Verify Data</strong></p>
<p>You can now search the index.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">GET</span> <span style="color:#960050;background-color:#1e0010">litellm-test-index/_search</span>
</span></span></code></pre></div><p><em>Note: You will not see the embedding vectors in the <code>_source</code> output. This is by design to save storage space. To learn more about this behavior, check out the <a href="https://www.elastic.co/search-labs/blog/elasticsearch-exclude-vectors-from-source">Elastic Search Labs blog on excluding vectors from source</a>.</em></p>
<p><strong>4. Perform Semantic Query</strong></p>
<p>Finally, let&rsquo;s run a natural language search. The query &ldquo;tools for deploying software&rdquo; does not exist in our text, but the vector search identifies the semantic relationship with &ldquo;Docker containers.&rdquo;</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">GET</span> <span style="color:#960050;background-color:#1e0010">/litellm-test-index/_search</span>
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span> <span style="color:#f92672">&#34;query&#34;</span>: {
</span></span><span style="display:flex;"><span>   <span style="color:#f92672">&#34;semantic&#34;</span>: {
</span></span><span style="display:flex;"><span>     <span style="color:#f92672">&#34;field&#34;</span>: <span style="color:#e6db74">&#34;content&#34;</span>,
</span></span><span style="display:flex;"><span>     <span style="color:#f92672">&#34;query&#34;</span>: <span style="color:#e6db74">&#34;tools for deploying software&#34;</span>
</span></span><span style="display:flex;"><span>   }
</span></span><span style="display:flex;"><span> }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><em>Output</em></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;took&#34;</span>: <span style="color:#ae81ff">501</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;timed_out&#34;</span>: <span style="color:#66d9ef">false</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;_shards&#34;</span>: {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;total&#34;</span>: <span style="color:#ae81ff">10</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;successful&#34;</span>: <span style="color:#ae81ff">10</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;skipped&#34;</span>: <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;failed&#34;</span>: <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;hits&#34;</span>: {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;total&#34;</span>: {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;value&#34;</span>: <span style="color:#ae81ff">3</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;relation&#34;</span>: <span style="color:#e6db74">&#34;eq&#34;</span>
</span></span><span style="display:flex;"><span>    },
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;max_score&#34;</span>: <span style="color:#ae81ff">0.7422092</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;hits&#34;</span>: [
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_index&#34;</span>: <span style="color:#e6db74">&#34;litellm-test-index&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_id&#34;</span>: <span style="color:#e6db74">&#34;UZR4pJsBGjew_vztklFP&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_score&#34;</span>: <span style="color:#ae81ff">0.7422092</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_source&#34;</span>: {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;content&#34;</span>: <span style="color:#e6db74">&#34;Docker containers make deployment consistent and easy.&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;category&#34;</span>: <span style="color:#e6db74">&#34;tech&#34;</span>
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>      },
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_index&#34;</span>: <span style="color:#e6db74">&#34;litellm-test-index&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_id&#34;</span>: <span style="color:#e6db74">&#34;UJR4pJsBGjew_vztklFP&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_score&#34;</span>: <span style="color:#ae81ff">0.68897665</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_source&#34;</span>: {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;content&#34;</span>: <span style="color:#e6db74">&#34;Artificial intelligence is transforming software development.&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;category&#34;</span>: <span style="color:#e6db74">&#34;tech&#34;</span>
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>      },
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_index&#34;</span>: <span style="color:#e6db74">&#34;litellm-test-index&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_id&#34;</span>: <span style="color:#e6db74">&#34;T5R4pJsBGjew_vztklFP&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_score&#34;</span>: <span style="color:#ae81ff">0.5035514</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_source&#34;</span>: {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;content&#34;</span>: <span style="color:#e6db74">&#34;The quick brown fox jumps over the lazy dog.&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;category&#34;</span>: <span style="color:#e6db74">&#34;animals&#34;</span>
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>    ]
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><h3 id="conclusion">Conclusion</h3>
<p>This architecture demonstrates the power of decoupling your model provider from your search engine. By using <strong>LiteLLM</strong> as a standardized proxy, you gain the flexibility to swap underlying models without breaking your application. Simultaneously, <strong>Elasticsearch&rsquo;s Vector Search</strong> leverages these embeddings to provide deep semantic understanding.</p>
<p>Together, LiteLLM and Elasticsearch create a robust, future-proof foundation for building intelligent search applications that go far beyond simple keyword matching.</p>
<p>Happy searching!</p>
]]></content:encoded>
    </item>
    <item>
      <title>Hybrid Search Done Right: Stop Calling Metadata Filters &#34;Hybrid&#34;</title>
      <link>https://ashish.one/blogs/elastic/true-hybrid-search/</link>
      <pubDate>Mon, 25 Aug 2025 12:09:27 +0530</pubDate>
      <guid>https://ashish.one/blogs/elastic/true-hybrid-search/</guid>
      <description>&lt;h1 id=&#34;hybrid-search-done-right-stop-calling-metadata-filters-hybrid&#34;&gt;Hybrid Search Done Right: Stop Calling Metadata Filters &amp;ldquo;Hybrid&amp;rdquo;&lt;/h1&gt;
&lt;p&gt;Everyone’s talking about &lt;strong&gt;hybrid search&lt;/strong&gt; right now.
But here’s the uncomfortable truth:&lt;/p&gt;
&lt;p&gt;👉 Just because you glued vector search onto your database and added metadata filters doesn’t mean you’ve built &lt;em&gt;true&lt;/em&gt; hybrid search.&lt;/p&gt;
&lt;p&gt;That’s like duct-taping a spoiler on a hatchback and calling it a race car. 🚗💨&lt;/p&gt;
&lt;p&gt;Hybrid search is more than just “keyword + vector + filter.”
It’s about &lt;strong&gt;field-level design, reranking, scoring, and scale&lt;/strong&gt;.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h1 id="hybrid-search-done-right-stop-calling-metadata-filters-hybrid">Hybrid Search Done Right: Stop Calling Metadata Filters &ldquo;Hybrid&rdquo;</h1>
<p>Everyone’s talking about <strong>hybrid search</strong> right now.
But here’s the uncomfortable truth:</p>
<p>👉 Just because you glued vector search onto your database and added metadata filters doesn’t mean you’ve built <em>true</em> hybrid search.</p>
<p>That’s like duct-taping a spoiler on a hatchback and calling it a race car. 🚗💨</p>
<p>Hybrid search is more than just “keyword + vector + filter.”
It’s about <strong>field-level design, reranking, scoring, and scale</strong>.</p>
<p>Let’s break this down.</p>
<hr>
<h2 id="field-level-truth-not-every-field-deserves-semantic-search">Field-Level Truth: Not Every Field Deserves Semantic Search</h2>
<p>The biggest mistake I see:
Teams running semantic + lexical search on <em>every</em> field in their JSON docs.</p>
<p>That’s how you kill relevance.</p>
<h3 id="lexical-only-fields">Lexical-Only Fields</h3>
<p>These work best with exact match:</p>
<ul>
<li><code>title</code></li>
<li><code>name</code></li>
<li><code>issue_id</code></li>
<li><code>category</code></li>
<li><code>tags</code></li>
</ul>
<p>If I search for <code>issue_id: 1245</code>, I want <strong>1245</strong> — not “similar looking IDs.”</p>
<h3 id="semantic-only-fields">Semantic-Only Fields</h3>
<p>These benefit from embeddings:</p>
<ul>
<li><code>product_description</code></li>
<li><code>movie_storyline</code></li>
<li><code>customer_feedback</code></li>
<li><code>reviews</code></li>
</ul>
<p>This is where meaning &gt; keywords.
“Battery dies too quickly” should match with “poor battery life.”</p>
<h3 id="the-formula-that-works">The Formula That Works</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>Final Score = RRF(
</span></span><span style="display:flex;"><span>   Lexical(title, name, category) +
</span></span><span style="display:flex;"><span>   Semantic(description, feedback, reviews)
</span></span><span style="display:flex;"><span>)
</span></span></code></pre></div><p>Hybrid works when <strong>each field is treated for what it is</strong>.</p>
<h3 id="quick-reference-table">Quick Reference Table</h3>
<table>
  <thead>
      <tr>
          <th>Field Type</th>
          <th>Example Fields</th>
          <th>Best Search Method</th>
          <th>Why?</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Metadata / Identifiers</td>
          <td><code>id</code>, <code>issue_id</code>, <code>category</code></td>
          <td>Lexical</td>
          <td>Needs exact matching, filtering</td>
      </tr>
      <tr>
          <td>Structured Short Text</td>
          <td><code>title</code>, <code>name</code>, <code>tags</code></td>
          <td>Lexical</td>
          <td>Precision &gt; meaning</td>
      </tr>
      <tr>
          <td>Unstructured Text</td>
          <td><code>description</code>, <code>reviews</code></td>
          <td>Semantic</td>
          <td>Context + meaning matter</td>
      </tr>
  </tbody>
</table>
<hr>
<h2 id="metadata-filters-keep-them-lexical">Metadata Filters: Keep Them Lexical</h2>
<p>One of the biggest anti-patterns: vectorizing filters.</p>
<p>Filters are not semantic. They should remain <strong>exact</strong>.</p>
<ul>
<li>Price → numeric filters</li>
<li>Stock availability → boolean</li>
<li>Categories, IDs → keyword</li>
<li>Timestamps, geo → structured fields</li>
</ul>
<p>Search is about <em>precision here</em>. If you fuzzy up filters with embeddings, you’ll tank user trust.</p>
<hr>
<h2 id="hybrid--metadata-filters--vectors">Hybrid ≠ Metadata Filters + Vectors</h2>
<p>Here’s the thing. Some vector DBs shout <em>“we support keyword search now!”</em>
But if you look closer, it’s often:</p>
<ul>
<li>A bolted-on library</li>
<li>Or patched-in metadata filters</li>
</ul>
<p>Yeah, technically it works.
But <strong>that’s not hybrid</strong>.</p>
<p>Search is not just filters.</p>
<hr>
<h2 id="what-real-hybrid-search-looks-like">What Real Hybrid Search Looks Like</h2>
<p>Let’s talk the real stuff beyond filters + vectors:</p>
<ul>
<li><strong>Autocomplete</strong> — search-as-you-type, phrase suggesters, boosting, user-friendly completion.</li>
<li><strong>Facets</strong> — powerful aggregations: geo boundaries, date histograms, bucketing. Not just string counts.</li>
<li><strong>Native rescoring</strong> — query rescorer, rank features, boosting for freshness, popularity, personalization.</li>
<li><strong>Rich documents</strong> — nested JSON, arrays, geo points, IPs. Search isn’t flat.</li>
<li><strong>Geo Search</strong> — aggregations, polygons, proximity scoring. Beyond just “in radius.”</li>
<li><strong>Access control</strong> — index → document → field level security. For lexical <strong>and</strong> vector fields.</li>
<li><strong>Data enrichment pipelines</strong> — entity extraction, tagging, embeddings, LLM-based enrichment.</li>
<li><strong>Scalability</strong> — petabytes of data, tiered storage, lifecycle management. Search doesn’t stop at 10M docs.</li>
</ul>
<p>This is hybrid.</p>
<hr>
<h2 id="vectors-ask-the-hard-questions">Vectors: Ask the Hard Questions</h2>
<p>Not all vector support is equal. Check:</p>
<ul>
<li>Is vector search <strong>native to the engine</strong> or bolted on?</li>
<li>Query types: KNN, ANN, hybrid filtering?</li>
<li>Can it run at scale with good recall + low latency?</li>
<li>Quantization: int4, int8, binary, advanced methods like <strong>BBQ (Better Binary Quantization)</strong>?</li>
<li>Filters on HNSW: is it pre-filtering or filter-aware indexing (like ACORN)?</li>
<li>Can it blend semantic + lexical scoring at query time?
<ul>
<li>RRF (Reciprocal Rank Fusion)</li>
<li>Linear retrievers</li>
<li>Semantic reranking with LLMs</li>
</ul>
</li>
</ul>
<p>If your engine can’t do these, it’s not serious about hybrid.</p>
<hr>
<h2 id="implementation-note-one-query-should-do-it">Implementation Note: One Query Should Do It</h2>
<p>If you need to stitch 3–4 services together just to get:</p>
<ul>
<li>Facets</li>
<li>Filters</li>
<li>Semantic results</li>
<li>Lexical results</li>
<li>Reranking</li>
</ul>
<p>…you’re adding <strong>latency + complexity</strong>.</p>
<p>A true hybrid engine should give you everything in <strong>one structured query</strong>.</p>
<hr>
<h2 id="practical-takeaways">Practical Takeaways</h2>
<ol>
<li><strong>Not all fields deserve semantic.</strong> Treat fields differently.</li>
<li><strong>Filters are lexical.</strong> Stop semantic-izing metadata.</li>
<li><strong>Hybrid = lexical + semantic + rescoring + scale.</strong> Not just bolted-on keyword support.</li>
<li><strong>Evaluate vectors deeply.</strong> Native support, quantization, filtering, reranking.</li>
<li><strong>One query &gt; stitched services.</strong> Hybrid done right = clean pipeline, low latency.</li>
</ol>
<hr>
<h2 id="closing-thoughts">Closing Thoughts</h2>
<p>Hybrid search is not a checkbox.
It’s about designing for <strong>relevance + scale + control</strong>.</p>
<p>If your “hybrid” is just vectors + filters, you’ve built a demo — not a real search engine.</p>
<p>True hybrid is <strong>Lexical + Semantic + Scoring + Access + Scale + Control</strong>.
That’s when search feels natural, accurate, and production-ready.</p>
<hr>
]]></content:encoded>
    </item>
    <item>
      <title>Laracon 2024</title>
      <link>https://ashish.one/talks/laracon-2024/</link>
      <pubDate>Mon, 25 Aug 2025 11:29:16 +0530</pubDate>
      <guid>https://ashish.one/talks/laracon-2024/</guid>
      <description>&lt;h1 id=&#34;-talk-summary-no-code-rag-chatbot-with-php-llms--elasticsearch&#34;&gt;🎤 Talk Summary: No-Code RAG Chatbot with PHP, LLMs &amp;amp; Elasticsearch&lt;/h1&gt;
&lt;p&gt;&lt;strong&gt;Speaker:&lt;/strong&gt; Ashish Diwali (Senior Developer Advocate, Elastic)&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;-introduction&#34;&gt;🔑 Introduction&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Topic: Integrating &lt;strong&gt;Generative AI (LLMs)&lt;/strong&gt; with &lt;strong&gt;PHP&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Goal: Show how to build &lt;strong&gt;chat assistants, semantic search, and vector search&lt;/strong&gt; without heavy ML expertise.&lt;/li&gt;
&lt;li&gt;Demo focus: Using &lt;strong&gt;Elasticsearch + PHP + LLM (LLaMA 3.1)&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&#34;-core-concepts&#34;&gt;🧩 Core Concepts&lt;/h2&gt;
&lt;h3 id=&#34;1-prompt-engineering&#34;&gt;1. Prompt Engineering&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;LLMs generate responses based on prompts → predicting next words.&lt;/li&gt;
&lt;li&gt;Techniques:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Zero-shot inference&lt;/strong&gt; → direct classification or tagging.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;One-shot inference&lt;/strong&gt; → provide one example in the prompt.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Few-shot inference&lt;/strong&gt; → multiple examples → useful for structured outputs (SQL, JSON, XML).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Iteration + context = &lt;strong&gt;In-context learning (ICL)&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;2-llm-limitations&#34;&gt;2. LLM Limitations&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;❌ Hallucinations (wrong answers).&lt;/li&gt;
&lt;li&gt;❌ Complex to build/train from scratch.&lt;/li&gt;
&lt;li&gt;❌ No real-time / private data access.&lt;/li&gt;
&lt;li&gt;❌ Privacy &amp;amp; security concerns (especially in banking, public sector).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;3-rag-retrieval-augmented-generation&#34;&gt;3. RAG (Retrieval-Augmented Generation)&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Solution to limitations.&lt;/li&gt;
&lt;li&gt;Workflow:
&lt;ol&gt;
&lt;li&gt;User query → hits database/vector DB (e.g., Elasticsearch).&lt;/li&gt;
&lt;li&gt;Retrieve &lt;strong&gt;top 5–10 relevant docs&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Pass as context window → LLM generates accurate answer.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;Benefits:
&lt;ul&gt;
&lt;li&gt;Grounded responses.&lt;/li&gt;
&lt;li&gt;Works with private data.&lt;/li&gt;
&lt;li&gt;Avoids retraining large models.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&#34;-semantic--vector-search&#34;&gt;🔍 Semantic &amp;amp; Vector Search&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Semantic Search:&lt;/strong&gt; Understands meaning, not just keywords.
&lt;ul&gt;
&lt;li&gt;Example: “best city” ↔ “beautiful city.”&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Vector Search:&lt;/strong&gt; Text, images, and audio converted into embeddings (arrays of floats).
&lt;ul&gt;
&lt;li&gt;Enables image search, recommendation systems, music search (via humming).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Similarity algorithms:&lt;/strong&gt; cosine similarity, dot product, nearest neighbors.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&#34;-tools--demo&#34;&gt;🛠️ Tools &amp;amp; Demo&lt;/h2&gt;
&lt;h3 id=&#34;elephant-library-php&#34;&gt;Elephant Library (PHP)&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Open-source PHP library for GenAI apps.&lt;/li&gt;
&lt;li&gt;Supports:
&lt;ul&gt;
&lt;li&gt;LLMs: OpenAI, Mistral, Anthropic, LLaMA.&lt;/li&gt;
&lt;li&gt;Vector DBs: Elasticsearch, Pinecone, Chroma, etc.&lt;/li&gt;
&lt;li&gt;Features: document chunking, embedding generation, semantic retrieval, Q&amp;amp;A (RAG).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;demo-flow&#34;&gt;Demo Flow&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Ingestion&lt;/strong&gt;:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h1 id="-talk-summary-no-code-rag-chatbot-with-php-llms--elasticsearch">🎤 Talk Summary: No-Code RAG Chatbot with PHP, LLMs &amp; Elasticsearch</h1>
<p><strong>Speaker:</strong> Ashish Diwali (Senior Developer Advocate, Elastic)</p>
<hr>
<h2 id="-introduction">🔑 Introduction</h2>
<ul>
<li>Topic: Integrating <strong>Generative AI (LLMs)</strong> with <strong>PHP</strong>.</li>
<li>Goal: Show how to build <strong>chat assistants, semantic search, and vector search</strong> without heavy ML expertise.</li>
<li>Demo focus: Using <strong>Elasticsearch + PHP + LLM (LLaMA 3.1)</strong>.</li>
</ul>
<hr>
<h2 id="-core-concepts">🧩 Core Concepts</h2>
<h3 id="1-prompt-engineering">1. Prompt Engineering</h3>
<ul>
<li>LLMs generate responses based on prompts → predicting next words.</li>
<li>Techniques:
<ul>
<li><strong>Zero-shot inference</strong> → direct classification or tagging.</li>
<li><strong>One-shot inference</strong> → provide one example in the prompt.</li>
<li><strong>Few-shot inference</strong> → multiple examples → useful for structured outputs (SQL, JSON, XML).</li>
</ul>
</li>
<li>Iteration + context = <strong>In-context learning (ICL)</strong>.</li>
</ul>
<h3 id="2-llm-limitations">2. LLM Limitations</h3>
<ul>
<li>❌ Hallucinations (wrong answers).</li>
<li>❌ Complex to build/train from scratch.</li>
<li>❌ No real-time / private data access.</li>
<li>❌ Privacy &amp; security concerns (especially in banking, public sector).</li>
</ul>
<h3 id="3-rag-retrieval-augmented-generation">3. RAG (Retrieval-Augmented Generation)</h3>
<ul>
<li>Solution to limitations.</li>
<li>Workflow:
<ol>
<li>User query → hits database/vector DB (e.g., Elasticsearch).</li>
<li>Retrieve <strong>top 5–10 relevant docs</strong>.</li>
<li>Pass as context window → LLM generates accurate answer.</li>
</ol>
</li>
<li>Benefits:
<ul>
<li>Grounded responses.</li>
<li>Works with private data.</li>
<li>Avoids retraining large models.</li>
</ul>
</li>
</ul>
<hr>
<h2 id="-semantic--vector-search">🔍 Semantic &amp; Vector Search</h2>
<ul>
<li><strong>Semantic Search:</strong> Understands meaning, not just keywords.
<ul>
<li>Example: “best city” ↔ “beautiful city.”</li>
</ul>
</li>
<li><strong>Vector Search:</strong> Text, images, and audio converted into embeddings (arrays of floats).
<ul>
<li>Enables image search, recommendation systems, music search (via humming).</li>
</ul>
</li>
<li><strong>Similarity algorithms:</strong> cosine similarity, dot product, nearest neighbors.</li>
</ul>
<hr>
<h2 id="-tools--demo">🛠️ Tools &amp; Demo</h2>
<h3 id="elephant-library-php">Elephant Library (PHP)</h3>
<ul>
<li>Open-source PHP library for GenAI apps.</li>
<li>Supports:
<ul>
<li>LLMs: OpenAI, Mistral, Anthropic, LLaMA.</li>
<li>Vector DBs: Elasticsearch, Pinecone, Chroma, etc.</li>
<li>Features: document chunking, embedding generation, semantic retrieval, Q&amp;A (RAG).</li>
</ul>
</li>
</ul>
<h3 id="demo-flow">Demo Flow</h3>
<ol>
<li>
<p><strong>Ingestion</strong>:</p>
<ul>
<li>Chunk PDF into smaller pieces (800 chars).</li>
<li>Generate embeddings with LLaMA.</li>
<li>Store text + vectors in Elasticsearch.</li>
</ul>
</li>
<li>
<p><strong>Querying</strong>:</p>
<ul>
<li>User question → hits Elasticsearch.</li>
<li>Retrieve top 10 docs.</li>
<li>Send docs + query → LLaMA → response.</li>
</ul>
</li>
<li>
<p><strong>Examples</strong>:</p>
<ul>
<li><em>“Who won the Nobel Prize in Physics 2024?”</em> → Retrieved correct answer from PDF context.</li>
<li><em>“How do brain neural networks work?”</em> → Summarized based on provided docs.</li>
<li><em>“Who won ICC Championship 2025?”</em> → No irrelevant hallucination (kept within context).</li>
</ul>
</li>
</ol>
<hr>
<h2 id="-key-takeaways">🎯 Key Takeaways</h2>
<ul>
<li><strong>Don’t train your own LLM</strong> → use <strong>RAG + search</strong> to build assistants on private data.</li>
<li><strong>Elasticsearch</strong> is a powerful vector DB for semantic + hybrid search.</li>
<li><strong>PHP + Elephant</strong> makes building RAG chatbots accessible for web developers.</li>
<li>RAG powers most modern chat assistants today.</li>
</ul>
<hr>


    
    <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/qDFct7oeRss?autoplay=0&controls=1&end=0&loop=0&mute=0&start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"
      ></iframe>
    </div>

]]></content:encoded>
    </item>
    <item>
      <title>AWS Community Day Mumbai 2024</title>
      <link>https://ashish.one/talks/aws-communtiy-day-mumbai-2024/</link>
      <pubDate>Mon, 25 Aug 2025 10:18:25 +0530</pubDate>
      <guid>https://ashish.one/talks/aws-communtiy-day-mumbai-2024/</guid>
      <description>&lt;h1 id=&#34;-no-code-chatbot-with-elasticsearch--aws-bedrock-talk-summary&#34;&gt;🚀 No-Code Chatbot with Elasticsearch + AWS Bedrock (Talk Summary)&lt;/h1&gt;
&lt;p&gt;&lt;strong&gt;Speaker:&lt;/strong&gt; Ashish (Senior Developer Advocate, Elastic)&lt;br&gt;
&lt;strong&gt;Event:&lt;/strong&gt; AWS Community Day Mumbai 2024&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;-why-search-still-matters-with-llms&#34;&gt;🔑 Why Search Still Matters with LLMs&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;LLMs (like ChatGPT) are powerful but face:
&lt;ul&gt;
&lt;li&gt;❌ Hallucinations&lt;/li&gt;
&lt;li&gt;💰 High cost per query&lt;/li&gt;
&lt;li&gt;🔒 No access to private / real-time data&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;✅ Search grounds LLMs in &lt;strong&gt;reliable, domain-specific info&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&#34;-elasticsearch-capabilities&#34;&gt;⚡ Elasticsearch Capabilities&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Traditional &lt;strong&gt;keyword search&lt;/strong&gt; + modern &lt;strong&gt;vector search&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Real-world use cases:
&lt;ul&gt;
&lt;li&gt;📍 Geospatial queries (ride-sharing, food delivery)&lt;/li&gt;
&lt;li&gt;❤️ Matchmaking&lt;/li&gt;
&lt;li&gt;📊 Observability dashboards&lt;/li&gt;
&lt;li&gt;📝 Centralized logging (Elastic Stack: Elasticsearch, Kibana, Beats, Logstash)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&#34;-retrieval-augmented-generation-rag&#34;&gt;🤖 Retrieval-Augmented Generation (RAG)&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Workflow:&lt;/strong&gt;&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h1 id="-no-code-chatbot-with-elasticsearch--aws-bedrock-talk-summary">🚀 No-Code Chatbot with Elasticsearch + AWS Bedrock (Talk Summary)</h1>
<p><strong>Speaker:</strong> Ashish (Senior Developer Advocate, Elastic)<br>
<strong>Event:</strong> AWS Community Day Mumbai 2024</p>
<hr>
<h2 id="-why-search-still-matters-with-llms">🔑 Why Search Still Matters with LLMs</h2>
<ul>
<li>LLMs (like ChatGPT) are powerful but face:
<ul>
<li>❌ Hallucinations</li>
<li>💰 High cost per query</li>
<li>🔒 No access to private / real-time data</li>
</ul>
</li>
<li>✅ Search grounds LLMs in <strong>reliable, domain-specific info</strong>.</li>
</ul>
<hr>
<h2 id="-elasticsearch-capabilities">⚡ Elasticsearch Capabilities</h2>
<ul>
<li>Traditional <strong>keyword search</strong> + modern <strong>vector search</strong>.</li>
<li>Real-world use cases:
<ul>
<li>📍 Geospatial queries (ride-sharing, food delivery)</li>
<li>❤️ Matchmaking</li>
<li>📊 Observability dashboards</li>
<li>📝 Centralized logging (Elastic Stack: Elasticsearch, Kibana, Beats, Logstash)</li>
</ul>
</li>
</ul>
<hr>
<h2 id="-retrieval-augmented-generation-rag">🤖 Retrieval-Augmented Generation (RAG)</h2>
<p><strong>Workflow:</strong></p>
<ol>
<li>User query →</li>
<li>Elasticsearch retrieves relevant documents →</li>
<li>Context passed to AWS Bedrock LLM →</li>
<li>LLM generates grounded answers</li>
</ol>
<p>👉 Reduces hallucination, enables <strong>chatbots on private data</strong>.</p>
<hr>
<h2 id="-demo-stack">🛠️ Demo Stack</h2>
<ul>
<li><strong>Flowise AI</strong> → No-code, drag &amp; drop RAG builder</li>
<li><strong>Steps:</strong>
<ol>
<li>Ingest data (JSON, PDFs, web crawl)</li>
<li>Chunk text</li>
<li>Generate embeddings (Amazon Titan)</li>
<li>Store embeddings + text in Elasticsearch</li>
<li>Connect Bedrock LLM for Q&amp;A</li>
</ol>
</li>
</ul>
<hr>
<h2 id="-extensions">🌐 Extensions</h2>
<ul>
<li>Text search ✅</li>
<li>Image search 🖼️</li>
<li>Audio search (e.g., humming a tune) 🎵</li>
<li>Multimodal experiences 🤝</li>
</ul>
<hr>
<h2 id="-key-takeaway">🎯 Key Takeaway</h2>
<p>With <strong>Elasticsearch + AWS Bedrock + Flowise AI</strong>, developers can build <strong>domain-specific, no-code RAG chatbots</strong> that combine:</p>
<ul>
<li>The <strong>precision of search</strong> 🔍</li>
<li>The <strong>fluency of LLMs</strong> 💬</li>
</ul>
<hr>
<h1 id="talk-video">Talk video</h1>


    
    <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/ODy_xZIKU-s?autoplay=0&controls=1&end=0&loop=0&mute=0&start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"
      ></iframe>
    </div>

]]></content:encoded>
    </item>
    <item>
      <title>Set Up TLS for Elasticsearch on Public IP / Domain</title>
      <link>https://ashish.one/gist/setup-tls-elasticsearch/</link>
      <pubDate>Wed, 23 Oct 2024 20:29:51 +0530</pubDate>
      <guid>https://ashish.one/gist/setup-tls-elasticsearch/</guid>
      <description>&lt;p&gt;This is a quick gist to demonstrate how you can run Elasticsearch securely with TLS on a public IP or domain. Sometimes, we need to spin up Elasticsearch for a development environment. In that case, you can follow these quick steps.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note - This gist is not recommended for production multinode cluster. As I only tested on single node cluster. If you have a multi-node cluster please follow the official &lt;a href=&#34;https://www.elastic.co/guide/en/elasticsearch/reference/current/manually-configure-security.html&#34;&gt;guide&lt;/a&gt;.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>This is a quick gist to demonstrate how you can run Elasticsearch securely with TLS on a public IP or domain. Sometimes, we need to spin up Elasticsearch for a development environment. In that case, you can follow these quick steps.</p>
<blockquote>
<p>Note - This gist is not recommended for production multinode cluster. As I only tested on single node cluster. If you have a multi-node cluster please follow the official <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/manually-configure-security.html">guide</a>.</p>
</blockquote>
<h1 id="elasticsearch-installation">Elasticsearch Installation</h1>
<ol>
<li>I created a VM instance on GCP. Here are the details -</li>
</ol>
<p>OS: <code>Ubuntu 22.04</code><br>
Machine type: <code>e2-standard-4</code><br>
Configuration: <code>4 CPU, 16 GB RAM</code></p>
<ol start="2">
<li>
<p><a href="https://cloud.google.com/compute/docs/ip-addresses/configure-static-external-ip-address">Configure static external IP</a> for newly created VM or ensure your VM is accessible from the public IP.</p>
</li>
<li>
<p>Installed Elasticsearch from <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/targz.html">Archive</a>.</p>
</li>
</ol>
<p>You can <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/targz.html#_check_that_elasticsearch_is_running">verify</a> if Elasticsearch is running or not.</p>
<p>Get into the <code>$ES_HOME</code> folder -</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cd elasticsearch-<span style="color:#f92672">{</span>version<span style="color:#f92672">}</span>/
</span></span></code></pre></div><p>In my case it was</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cd elasticsearch-8.15.3/
</span></span></code></pre></div><hr>
<h1 id="default-tls-setup">Default TLS setup</h1>
<p>When you install Elasticsearch, By default it will generate a TLS certificate for the host <code>localhost</code> and IP <code>127.0.0.1</code>.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>ls config/certs/
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>http.p12  http_ca.crt  transport.p12
</span></span></code></pre></div><p>CURL call -</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>curl --cacert $ES_HOME/config/certs/http_ca.crt -u elastic:pass https://localhost:9200
</span></span></code></pre></div><p>OR</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>curl --cacert $ES_HOME/config/certs/http_ca.crt -u elastic:pass https://127.0.0.1:9200
</span></span></code></pre></div><p>Response</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;name&#34;</span> : <span style="color:#e6db74">&#34;benchmark1&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;cluster_name&#34;</span> : <span style="color:#e6db74">&#34;elasticsearch&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;cluster_uuid&#34;</span> : <span style="color:#e6db74">&#34;kqZsQ5WrTAWnlFmYbyMQWw&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;version&#34;</span> : {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;number&#34;</span> : <span style="color:#e6db74">&#34;8.15.3&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;build_flavor&#34;</span> : <span style="color:#e6db74">&#34;default&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;build_type&#34;</span> : <span style="color:#e6db74">&#34;tar&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;build_hash&#34;</span> : <span style="color:#e6db74">&#34;f97532e680b555c3a05e73a74c28afb666923018&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;build_date&#34;</span> : <span style="color:#e6db74">&#34;2024-10-09T22:08:00.328917561Z&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;build_snapshot&#34;</span> : <span style="color:#66d9ef">false</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;lucene_version&#34;</span> : <span style="color:#e6db74">&#34;9.11.1&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;minimum_wire_compatibility_version&#34;</span> : <span style="color:#e6db74">&#34;7.17.0&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;minimum_index_compatibility_version&#34;</span> : <span style="color:#e6db74">&#34;7.0.0&#34;</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;tagline&#34;</span> : <span style="color:#e6db74">&#34;You Know, for Search&#34;</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>If you run the same CURL command using the public IP of the VM, It won’t work.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>curl --cacert $ES_HOME/config/certs/http_ca.crt -u elastic:pass https://x.x.x.x:9200
</span></span></code></pre></div><pre tabindex="0"><code>curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
</code></pre><p>It is giving an error because the certificate is not valid for the IP / Domain. However, you can call insecurely by adding <code>-k</code> which is not recommended for production use.</p>
<pre tabindex="0"><code>curl -k --cacert $ES_HOME/config/certs/http_ca.crt -u elastic:pass https://x.x.x.x:9200
</code></pre><hr>
<h1 id="generate-tls-certificate-for-the-public-ip--domain">Generate TLS certificate for the Public IP / Domain</h1>
<h2 id="1-lets-generate-the-new-local-certificate-authority-ca">1. Let&rsquo;s generate the new local certificate authority CA)</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>./bin/elasticsearch-certutil ca
</span></span></code></pre></div><pre tabindex="0"><code>This tool assists you in the generation of X.509 certificates and certificate
signing requests for use with SSL/TLS in the Elastic stack.

The &#39;ca&#39; mode generates a new &#39;certificate authority&#39;
This will create a new X.509 certificate and private key that can be used
to sign certificate when running in &#39;cert&#39; mode.

Use the &#39;ca-dn&#39; option if you wish to configure the &#39;distinguished name&#39;
of the certificate authority

By default the &#39;ca&#39; mode produces a single PKCS#12 output file which holds:
    * The CA certificate
    * The CA&#39;s private key

If you elect to generate PEM format certificates (the -pem option), then the output will
be a zip file containing individual files for the CA certificate and private key

Please enter the desired output file [elastic-stack-ca.p12]: 
Enter password for elastic-stack-ca.p12 :
</code></pre><p>I kept blank for the last two questions. But you can change the output file and set the Password.</p>
<p>It must have created a file <code>elastic-stack-ca.p12</code> in <code>$ES_HOME</code> directory.</p>
<h2 id="2-generate-the-certificate-using-newly-created-ca">2. Generate the Certificate using newly created CA</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>./bin/elasticsearch-certutil http
</span></span></code></pre></div><p>It will ask some questions -</p>
<ol>
<li>Generate a CSR? [y/N] <code>n</code></li>
<li>Use an existing CA? [y/N] <code>y</code></li>
<li>CA Path: <code>$ES_HOME/elastic-stack-ca.p12</code></li>
</ol>
<blockquote>
<p>You need to provide the absolute path for <code>elastic-stack-ca.p12</code>.</p>
</blockquote>
<ol start="4">
<li>Password for elastic-stack-ca.p12:</li>
</ol>
<blockquote>
<p>Type the password if you had set in Step 1. In my case, I&rsquo;ll keep it blank.</p>
</blockquote>
<ol start="5">
<li>
<p>For how long should your certificate be valid? [5y]</p>
</li>
<li>
<p>Generate a certificate per node? [y/N] <code>y</code></p>
</li>
<li>
<p>node #1 name: <code>benchmakr1.node</code></p>
</li>
<li>
<p>Which hostnames will be used to connect to benchmakr1.node?</p>
</li>
</ol>
<pre tabindex="0"><code>yourdomain.name  
localhost
</code></pre><ol start="9">
<li>Which IP addresses will be used to connect to benchmakr1.node?</li>
</ol>
<pre tabindex="0"><code>127.0.0.1  
x.x.x.x
</code></pre><blockquote>
<p>Add your public IP list.</p>
</blockquote>
<ol start="10">
<li>Do you wish to change any of these options? [y/N] <code>n</code></li>
<li>Generate additional certificates? [Y/n] <code>n</code></li>
<li>Provide a password for the &ldquo;http.p12&rdquo; file:</li>
</ol>
<blockquote>
<p>Type the password which you want to set and save it. I kept it as a blank.</p>
</blockquote>
<ol start="13">
<li>What filename should be used for the output zip file?</li>
</ol>
<p>It must have created <code>elasticsearch-ssl-http.zip</code> file</p>
<h2 id="3-set-httpp12">3. Set <code>http.p12</code></h2>
<p>Lets unzip</p>
<pre tabindex="0"><code>mkdir new-ssl
mv elasticsearch-ssl-http.zip new-ssl/
cd new-ssl/
unzip elasticsearch-ssl-http.zip
</code></pre><p>This will create two directory -</p>
<pre tabindex="0"><code>1. elasticsearch
2. kibana
</code></pre><p>go to the <code>$ES_HOME</code> directory</p>
<pre tabindex="0"><code>cd ..
</code></pre><p>Replace old <code>http.p12</code> with new.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cp new-ssl/elasticsearch/http.p12 config/certs/http.p12
</span></span></code></pre></div><h2 id="4-change-password-for-your-private-key-httpp12">4. Change password for your private key <code>http.p12</code></h2>
<pre tabindex="0"><code>./bin/elasticsearch-keystore add xpack.security.http.ssl.keystore.secure_password
</code></pre><blockquote>
<p>Setting xpack.security.http.ssl.keystore.secure_password already exists. Overwrite? [y/N] <code>y</code></p>
</blockquote>
<pre tabindex="0"><code>Enter value for xpack.security.http.ssl.keystore.secure_password:
</code></pre><p>Kept it as a blank in my case. But if you have set any password on <code>Step 2 (Question no. 12)</code>, Please enter the same password.</p>
<h2 id="5-restart-the-elasticsearch-and-verify">5. Restart the Elasticsearch and verify</h2>
<p>Restart the Elasticsearch.</p>
<p>Let&rsquo;s make the same CURL call with the newly generated CA in <code>kibana</code> folder</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>curl --cacert $ES_HOME/new-ssl/kibana/elasticsearch-ca.pem -u elastic:pass https://x.x.x.x:9200
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;name&#34;</span> : <span style="color:#e6db74">&#34;benchmark1&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;cluster_name&#34;</span> : <span style="color:#e6db74">&#34;elasticsearch&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;cluster_uuid&#34;</span> : <span style="color:#e6db74">&#34;kqZsQ5WrTAWnlFmYbyMQWw&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;version&#34;</span> : <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;number&#34;</span> : <span style="color:#e6db74">&#34;8.15.3&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;build_flavor&#34;</span> : <span style="color:#e6db74">&#34;default&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;build_type&#34;</span> : <span style="color:#e6db74">&#34;tar&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;build_hash&#34;</span> : <span style="color:#e6db74">&#34;f97532e680b555c3a05e73a74c28afb666923018&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;build_date&#34;</span> : <span style="color:#e6db74">&#34;2024-10-09T22:08:00.328917561Z&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;build_snapshot&#34;</span> : false,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;lucene_version&#34;</span> : <span style="color:#e6db74">&#34;9.11.1&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;minimum_wire_compatibility_version&#34;</span> : <span style="color:#e6db74">&#34;7.17.0&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;minimum_index_compatibility_version&#34;</span> : <span style="color:#e6db74">&#34;7.0.0&#34;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;tagline&#34;</span> : <span style="color:#e6db74">&#34;You Know, for Search&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><blockquote>
<p>This gist for single node cluster. But if you&rsquo;re looking to secure your cluster end to end, Go through the complete <a href="https://www.elastic.co/guide/en/elasticsearch/reference/8.15/secure-cluster.html">guide</a>.</p>
</blockquote>
]]></content:encoded>
    </item>
    <item>
      <title>Serverless Ahmedabad 2023: Monitoring serverless environment with Elastic observability</title>
      <link>https://ashish.one/talks/serverless-ahmedabad-2023-elastic-observability/</link>
      <pubDate>Mon, 03 Jun 2024 12:13:06 +0530</pubDate>
      <guid>https://ashish.one/talks/serverless-ahmedabad-2023-elastic-observability/</guid>
      <description>&lt;h1 id=&#34;introduction&#34;&gt;Introduction&lt;/h1&gt;
&lt;p&gt;Serverless architectures take on-demand tasks to the next level with event-driven scheduling of workloads. Elastic Observability gives you the same insights into your serverless activities as the rest of your environment. Gather logs and metrics from your serverless invocations and tie them together with traces from your serverless functions.&lt;/p&gt;
&lt;p&gt;For example Identify AWS Lambda latency issues, cold starts, and other invocation issues. Logs are collected with the rest of your telemetry data, so you can look at all your data in context, in one place.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h1 id="introduction">Introduction</h1>
<p>Serverless architectures take on-demand tasks to the next level with event-driven scheduling of workloads. Elastic Observability gives you the same insights into your serverless activities as the rest of your environment. Gather logs and metrics from your serverless invocations and tie them together with traces from your serverless functions.</p>
<p>For example Identify AWS Lambda latency issues, cold starts, and other invocation issues. Logs are collected with the rest of your telemetry data, so you can look at all your data in context, in one place.</p>
<h2 id="talk-video">Talk video</h2>


    
    <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/PCPAlMaqRFw?autoplay=0&controls=1&end=0&loop=0&mute=0&start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"
      ></iframe>
    </div>

]]></content:encoded>
    </item>
    <item>
      <title>GIDS 2024 - Smart Search with RAG: Elasticsearch Meets Language Models</title>
      <link>https://ashish.one/talks/gids-2024-rag/</link>
      <pubDate>Mon, 03 Jun 2024 12:12:06 +0530</pubDate>
      <guid>https://ashish.one/talks/gids-2024-rag/</guid>
      <description>&lt;h1 id=&#34;introduction&#34;&gt;Introduction&lt;/h1&gt;
&lt;p&gt;In today&amp;rsquo;s data-driven world, just having a search engine is not enough; the key is making it smart. Enter Elasticsearch Relevance Engine (ESRE) augmented with Retrieval Augmented Generation (RAG), a powerful solution
that marries Elasticsearch’s superior search capabilities with Large Language Models (LLMs) like ChatGPT for precise, contextual querying over proprietary datasets. This session is a hands-on guide that will show you how to amplify the power of Elasticsearch with advanced LLMs.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h1 id="introduction">Introduction</h1>
<p>In today&rsquo;s data-driven world, just having a search engine is not enough; the key is making it smart. Enter Elasticsearch Relevance Engine (ESRE) augmented with Retrieval Augmented Generation (RAG), a powerful solution
that marries Elasticsearch’s superior search capabilities with Large Language Models (LLMs) like ChatGPT for precise, contextual querying over proprietary datasets. This session is a hands-on guide that will show you how to amplify the power of Elasticsearch with advanced LLMs.</p>
<p>Key Takeaways:</p>
<ul>
<li>Learn how to supercharge Elasticsearch&rsquo;s BM25 algorithm with semantic search for results that are not just relevant but contextually accurate.</li>
<li>Discover how to plug in Large Language Models like OpenAI&rsquo;s ChatGPT to enable context-aware question-answering over your proprietary data.</li>
<li>Gain insights into the latest advancements in vector search within Lucene and Elasticsearch.</li>
<li>A quick live demo: Experience first-hand how ESRE, empowered by RAG, transforms a basic search query into a context-rich, highly relevant result..</li>
</ul>
<p>This talk is for you if you&rsquo;re grappling with search relevance issues and are looking for innovative ways to make your search smarter and more efficient. Whether you&rsquo;re a software developer, data engineer, or ML enthusiast, this session will equip you with the skills you need to build next-generation search capabilities.</p>
<h2 id="talk-video">Talk video</h2>


    
    <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/r1jO4TglsEg?autoplay=0&controls=1&end=0&loop=0&mute=0&start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"
      ></iframe>
    </div>

]]></content:encoded>
    </item>
    <item>
      <title>Convert json to nd-json for elasticsearch</title>
      <link>https://ashish.one/gist/json-to-ndjson-elasticsearch/</link>
      <pubDate>Fri, 29 Mar 2024 20:29:51 +0530</pubDate>
      <guid>https://ashish.one/gist/json-to-ndjson-elasticsearch/</guid>
      <description>&lt;p&gt;Convert JSON to nd-json for bulk indexing into Elasticsearch.&lt;/p&gt;
&lt;h3 id=&#34;moviesjson&#34;&gt;movies.json&lt;/h3&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;[
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_x&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Student of the Year 2&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_id&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;tt7255568&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;poster_path&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://upload.wikimedia.org/wikipedia/en/thumb/3/3c/Student_of_the_year_2_Poster.jpg/220px-Student_of_the_year_2_Poster.jpg&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wiki_link&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://en.wikipedia.org/wiki/Student_of_the_Year_2&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_y&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Student of the Year 2&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;original_title&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Student of the Year 2&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;is_adult&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;year_of_release&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2019&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;runtime&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;146&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;genres&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Drama|Romance|Sport&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_rating&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;2.5&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_votes&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;12671&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;story&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;A student must face off against bullies and overcome hurdles  both academic and romantic  to win his college&amp;#39;s coveted Student of the Year trophy.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;summary&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;A student must face off against bullies and overcome hurdles  both academic and romantic  to win his college&amp;#39;s coveted Student of the Year trophy.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;tagline&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;actors&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Tiger Shroff|Ananya Panday|Tara Sutaria|Aditya Seal|Manoj Pahwa|Ayesha Raza|Rajesh Kumar|Manasi Joshi Roy|Samir Soni|Gul Panag|Manjot Singh|Sahil Anand|Harsh Beniwal|Daljeet Singh Gujral|&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wins_nominations&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;release_date&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;10 May 2019 (USA)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  },
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_x&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;De De Pyaar De&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_id&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;tt8647400&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;poster_path&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://upload.wikimedia.org/wikipedia/en/thumb/c/c4/De_De_Pyaar_De_Poster.jpg/220px-De_De_Pyaar_De_Poster.jpg&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wiki_link&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://en.wikipedia.org/wiki/De_De_Pyaar_De&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_y&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;De De Pyaar De&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;original_title&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;De De Pyaar De&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;is_adult&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;year_of_release&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2019&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;runtime&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;135&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;genres&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Comedy|Romance&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_rating&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;6.6&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_votes&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;5387&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;story&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;a 50 year old Aashish living London away from his family fro many years He falls in love with a 26 year Ayesha.Thou officially not divorced from his first wife Manju.Aashish wants her permission to get married to Ayesha.Upon reaching his house in India  Ayesha finds that Aashish kids are of the same age as her.Aashish introduces Ayesha as his secretary to his family he also finds that his daughter is about to get married and VK whose become close family friend is trying to woo her Manju.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;summary&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;A 50-year-old single father faces disapproval from his family and his ex-wife when he falls in love with a 26-year-old woman.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;tagline&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;actors&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Ajay Devgn|Tabu|Rakul Preet Singh|Jimmy Sheirgill|Alok Nath|Madhumalti Kapoor|Harry Anton|Gergo Baranyi|Sammy John Heaney|Bhavin Bhanushali|Gandharv Dewan|Gulnaaz Khan|Kumud Mishra|Sunny Singh Nijjar|&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wins_nominations&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;release_date&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;17 May 2019 (USA)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  },
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_x&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;India&amp;#39;s Most Wanted (film)&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_id&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;tt8484942&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;poster_path&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://upload.wikimedia.org/wikipedia/en/a/ae/India%27s_Most_Wanted_poster.jpg&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wiki_link&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://en.wikipedia.org/wiki/India%27s_Most_Wanted_(film)&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_y&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;India&amp;#39;s Most Wanted&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;original_title&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;India&amp;#39;s Most Wanted&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;is_adult&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;year_of_release&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2019&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;runtime&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;123&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;genres&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Action|Thriller&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_rating&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;4.4&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_votes&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;1449&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;story&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;India&amp;#39;s Most Wanted is a Bollywood action thriller film directed by Raj Kumar Gupta and starring Arjun Kapoor. The film is about tracking a terrorist in a secret mission and arresting him without firing bullets. It pays tribute to unsung heroes of our society.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;summary&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;A group of intelligence officers embark on a top secret mission to track down a wanted international criminal.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;tagline&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;actors&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Arjun Kapoor|Sudev Nair|Rajesh Sharma|Prasanth|Santilal Mukherjee|&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wins_nominations&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;release_date&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;24 May 2019 (USA)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  },
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_x&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Yeh Hai India&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_id&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;tt5525846&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;poster_path&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://upload.wikimedia.org/wikipedia/en/thumb/d/db/Yeh_Hai_India_Official_Poster.jpg/220px-Yeh_Hai_India_Official_Poster.jpg&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wiki_link&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://en.wikipedia.org/wiki/Yeh_Hai_India&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_y&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Yeh Hai India&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;original_title&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Yeh Hai India&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;is_adult&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;year_of_release&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2017&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;runtime&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;128&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;genres&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Action|Adventure|Drama&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_rating&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;5.7&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_votes&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;169&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;story&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Yeh Hai India  follows the story of a 25 years old NRI  who is born and brought up in U.K and shares the same stereotype views of India  which is known for its vast population  pollution and poverty. However protagonist finds new development in media or probably an &amp;#39;other side of same coin&amp;#39; of India  which is also known for successful mars mission in first attempt  a nation which proudly holds title &amp;#39;God of Cricket&amp;#39; for Sachin Tendulkar  who is again an Indian and a nation which is known for its holy generosity with icons like Mother Teresa\&amp;#34;.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;summary&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Yeh Hai India  follows the story of a 25 years old NRI  who is born and brought up in UK. He shares the same stereotypical views about India that most NRIs have and how his perception changes.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;tagline&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;A Film for Every Indian&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;actors&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Gavie Chahal|Mohan Agashe|Mohan Joshi|Lom Harsh|&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wins_nominations&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2 wins &amp;amp; 1 nomination&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;release_date&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;24 May 2019 (India)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  },
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_x&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Kabir Singh&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_id&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;tt8983202&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;poster_path&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://upload.wikimedia.org/wikipedia/en/thumb/d/dc/Kabir_Singh.jpg/220px-Kabir_Singh.jpg&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wiki_link&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://en.wikipedia.org/wiki/Kabir_Singh&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_y&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Kabir Singh&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;original_title&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Kabir Singh&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;is_adult&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;year_of_release&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2019&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;runtime&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;173&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;genres&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Drama|Romance&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_rating&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;7.2&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_votes&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;20535&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;story&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;This Sandeep Vanga directorial is a remake of the 2017 Telugu movie Arjun Reddy. The plot revolves around an alcoholic surgeon battling temper issues. Things get worse as he watches the love of his life marry another man. High on emotions coupled with impressive action the film promises an intense watch.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;summary&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Kabir Singh is a remake of a Telugu movie Arjun Reddy (2017)  where a short-tempered house surgeon gets used to drugs and drinks when his girlfriend is forced to marry another person.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;tagline&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;actors&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Shahid Kapoor|Kiara Advani|Soham Majumdar|Arjan Bajwa|Suresh Oberoi|Kamini Kaushal|Adil Hussain|Nikita Dutta|Amit Sharma|Anurag Arora|Dolly Mattoo|Aanchal Chauhan|Suparna Marwah|Swati Seth|&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wins_nominations&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;release_date&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;20 June 2019 (USA)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  },
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_x&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Article 15 (film)&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_id&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;tt10324144&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;poster_path&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://upload.wikimedia.org/wikipedia/en/thumb/1/11/Article_15_Poster.jpg/220px-Article_15_Poster.jpg&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wiki_link&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://en.wikipedia.org/wiki/Article_15_(film)&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_y&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Article 15&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;original_title&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Article 15&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;is_adult&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;year_of_release&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2019&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;runtime&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;130&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;genres&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Crime|Drama&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_rating&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;8.3&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_votes&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;13417&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;story&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;In the rural heartlands of India  an upright police officer sets out on a crusade against violent caste-based crimes and discrimination.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;summary&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;In the rural heartlands of India  an upright police officer sets out on a crusade against violent caste-based crimes and discrimination.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;tagline&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Farq Bahut Kar Liya| Ab Farq Laayenge.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;actors&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Ayushmann Khurrana|Nassar|Manoj Pahwa|Kumud Mishra|Isha Talwar|Sayani Gupta|Mohammed Zeeshan Ayyub|Subhrajyoti Barat|Sushil Pandey|Aakash Dabhade|Ashish Verma|Ronjini Chakraborty|Veen|Sumbul Touqueer|&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wins_nominations&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;1 win&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;release_date&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;28 June 2019 (USA)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  },
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_x&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;One Day: Justice Delivered&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_id&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;tt8130558&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;poster_path&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://upload.wikimedia.org/wikipedia/en/f/f7/One_Day-_Justice_Delivered.jpg&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wiki_link&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://en.wikipedia.org/wiki/One_Day:_Justice_Delivered&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_y&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;One Day: Justice Delivered&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;original_title&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;One Day: Justice Delivered&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;is_adult&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;year_of_release&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2019&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;runtime&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;124&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;genres&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Action|Crime|Thriller&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_rating&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;6.8&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_votes&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;590&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;story&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;A Crime Branch Special Officer Investigates the Serial disappearance of high profile individuals in a state capital.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;summary&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;A Crime Branch Special Officer Investigates the Serial disappearance of high profile individuals in a state capital.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;tagline&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;actors&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Anupam Kher|Kumud Mishra|Esha Gupta|Zakir Hussain|Rajesh Sharma|Murli Sharma|Deepshika Nagpal|&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wins_nominations&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;release_date&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;5 July 2019 (India)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  },
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_x&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Super 30 (film)&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_id&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;tt7485048&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;poster_path&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://upload.wikimedia.org/wikipedia/en/thumb/2/29/Super_30_The_Film.jpg/220px-Super_30_The_Film.jpg&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wiki_link&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://en.wikipedia.org/wiki/Super_30_(film)&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_y&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Super 30&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;original_title&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Super 30&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;is_adult&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;year_of_release&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2019&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;runtime&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;154&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;genres&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Biography|Drama&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_rating&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;8.2&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_votes&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;13972&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;story&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Anand Kumar  a Mathematics genius from a modest family in Bihar who is made to believe that only a King&amp;#39;s son can become a king is on a mission to prove that even the poor man can create some of the world&amp;#39;s most genius minds. He starts a training program named &amp;#39;Super 30&amp;#39; to help 30 IIT aspirants crack the entrance test and make them highly successful professionals.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;summary&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Based on life of Patna-based mathematician Anand Kumar who runs the famed Super 30 program for IIT aspirants in Patna.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;tagline&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Inspired by the Life of Anand Kumar &amp;amp; His Students&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;actors&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Hrithik Roshan|Mrunal Thakur|Nandish Singh|Virendra Saxena|Sadhana Singh|Aditya Srivastava|Sanket Deshpande|Pankaj Tripathi|Vaibhav Gupta|Ali Haji|Rajesh Sharma|Deepali Kumar|Chittaranjan Giri|Ganesh Kumar|&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wins_nominations&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;release_date&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;12 July 2019 (USA)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  },
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_x&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Batla House&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_id&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;tt8869978&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;poster_path&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://upload.wikimedia.org/wikipedia/en/e/ed/Batla_House_poster.jpg&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wiki_link&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://en.wikipedia.org/wiki/Batla_House&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_y&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Batla House&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;original_title&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Batla House&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;is_adult&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;year_of_release&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2019&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;runtime&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;146&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;genres&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Action|Drama|Thriller&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_rating&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;7.3&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_votes&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;5556&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;story&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;This action thriller is based on the real-life incident of &amp;#39;Batla House Encounter&amp;#39;  officially known as Operation Batla House  to the silver screen. The incident took place on September 19  2008  against Indian Mujahideen (IM) terrorists in Batla House locality in Jamia Nagar  Delhi.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;summary&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;After a deadly encounter  a police officer works to prove that the police acted lawfully.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;tagline&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;The Story of India&amp;#39;s Most Decorated / Controversial Cop&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;actors&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;John Abraham|Nora Fatehi|Mrunal Thakur|Rajesh Sharma|Ravi Kishan|Sonam Arora|Sahidur Rahaman|Manish Chaudhary|Anil Rastogi|Kranti Prakash Jha|Amruta Sant|Anil Khopkar|Aditi Gulati|Jitendra Trehan|&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wins_nominations&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;release_date&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;15 August 2019 (USA)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  },
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_x&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Mission Mangal&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_id&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;tt9248972&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;poster_path&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://upload.wikimedia.org/wikipedia/en/thumb/b/b7/Mission_Mangal.jpg/220px-Mission_Mangal.jpg&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wiki_link&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://en.wikipedia.org/wiki/Mission_Mangal&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;title_y&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Mission Mangal&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;original_title&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Mission Mangal&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;is_adult&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;year_of_release&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2019&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;runtime&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;130&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;genres&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Drama|History&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_rating&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;6.5&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;imdb_votes&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;7165&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;story&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Based on true events of the Indian Space Research Organisation (ISRO) successfully launching the Mars Orbiter Mission (Mangalyaan)  making it the least expensive mission to Mars.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;summary&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Based on true events of the Indian Space Research Organisation (ISRO) successfully launching the Mars Orbiter Mission (Mangalyaan)  making it the least expensive mission to Mars.&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;tagline&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;This Independence Day...The Sky is Not the Limit&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;actors&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Akshay Kumar|Vidya Balan|Nithya Menon|Taapsee Pannu|Sonakshi Sinha|Kirti Kulhari|H.G. Dattatreya|Sharman Joshi|Sanjay Kapoor|Dalip Tahil|Vikram Gokhale|Mohammed Zeeshan Ayyub|Purab Kohli|&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;wins_nominations&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;release_date&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;15 August 2019 (USA)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  }
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Install &lt;code&gt;jq&lt;/code&gt; on your linux machine and hit below command&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Convert JSON to nd-json for bulk indexing into Elasticsearch.</p>
<h3 id="moviesjson">movies.json</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>[
</span></span><span style="display:flex;"><span>  {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_x&#34;</span>: <span style="color:#e6db74">&#34;Student of the Year 2&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_id&#34;</span>: <span style="color:#e6db74">&#34;tt7255568&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;poster_path&#34;</span>: <span style="color:#e6db74">&#34;https://upload.wikimedia.org/wikipedia/en/thumb/3/3c/Student_of_the_year_2_Poster.jpg/220px-Student_of_the_year_2_Poster.jpg&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wiki_link&#34;</span>: <span style="color:#e6db74">&#34;https://en.wikipedia.org/wiki/Student_of_the_Year_2&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_y&#34;</span>: <span style="color:#e6db74">&#34;Student of the Year 2&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;original_title&#34;</span>: <span style="color:#e6db74">&#34;Student of the Year 2&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;is_adult&#34;</span>: <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;year_of_release&#34;</span>: <span style="color:#e6db74">&#34;2019&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;runtime&#34;</span>: <span style="color:#e6db74">&#34;146&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;genres&#34;</span>: <span style="color:#e6db74">&#34;Drama|Romance|Sport&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_rating&#34;</span>: <span style="color:#ae81ff">2.5</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_votes&#34;</span>: <span style="color:#ae81ff">12671</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;story&#34;</span>: <span style="color:#e6db74">&#34;A student must face off against bullies and overcome hurdles  both academic and romantic  to win his college&#39;s coveted Student of the Year trophy.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;summary&#34;</span>: <span style="color:#e6db74">&#34;A student must face off against bullies and overcome hurdles  both academic and romantic  to win his college&#39;s coveted Student of the Year trophy.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;tagline&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;actors&#34;</span>: <span style="color:#e6db74">&#34;Tiger Shroff|Ananya Panday|Tara Sutaria|Aditya Seal|Manoj Pahwa|Ayesha Raza|Rajesh Kumar|Manasi Joshi Roy|Samir Soni|Gul Panag|Manjot Singh|Sahil Anand|Harsh Beniwal|Daljeet Singh Gujral|&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wins_nominations&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;release_date&#34;</span>: <span style="color:#e6db74">&#34;10 May 2019 (USA)&#34;</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_x&#34;</span>: <span style="color:#e6db74">&#34;De De Pyaar De&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_id&#34;</span>: <span style="color:#e6db74">&#34;tt8647400&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;poster_path&#34;</span>: <span style="color:#e6db74">&#34;https://upload.wikimedia.org/wikipedia/en/thumb/c/c4/De_De_Pyaar_De_Poster.jpg/220px-De_De_Pyaar_De_Poster.jpg&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wiki_link&#34;</span>: <span style="color:#e6db74">&#34;https://en.wikipedia.org/wiki/De_De_Pyaar_De&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_y&#34;</span>: <span style="color:#e6db74">&#34;De De Pyaar De&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;original_title&#34;</span>: <span style="color:#e6db74">&#34;De De Pyaar De&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;is_adult&#34;</span>: <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;year_of_release&#34;</span>: <span style="color:#e6db74">&#34;2019&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;runtime&#34;</span>: <span style="color:#e6db74">&#34;135&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;genres&#34;</span>: <span style="color:#e6db74">&#34;Comedy|Romance&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_rating&#34;</span>: <span style="color:#ae81ff">6.6</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_votes&#34;</span>: <span style="color:#ae81ff">5387</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;story&#34;</span>: <span style="color:#e6db74">&#34;a 50 year old Aashish living London away from his family fro many years He falls in love with a 26 year Ayesha.Thou officially not divorced from his first wife Manju.Aashish wants her permission to get married to Ayesha.Upon reaching his house in India  Ayesha finds that Aashish kids are of the same age as her.Aashish introduces Ayesha as his secretary to his family he also finds that his daughter is about to get married and VK whose become close family friend is trying to woo her Manju.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;summary&#34;</span>: <span style="color:#e6db74">&#34;A 50-year-old single father faces disapproval from his family and his ex-wife when he falls in love with a 26-year-old woman.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;tagline&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;actors&#34;</span>: <span style="color:#e6db74">&#34;Ajay Devgn|Tabu|Rakul Preet Singh|Jimmy Sheirgill|Alok Nath|Madhumalti Kapoor|Harry Anton|Gergo Baranyi|Sammy John Heaney|Bhavin Bhanushali|Gandharv Dewan|Gulnaaz Khan|Kumud Mishra|Sunny Singh Nijjar|&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wins_nominations&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;release_date&#34;</span>: <span style="color:#e6db74">&#34;17 May 2019 (USA)&#34;</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_x&#34;</span>: <span style="color:#e6db74">&#34;India&#39;s Most Wanted (film)&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_id&#34;</span>: <span style="color:#e6db74">&#34;tt8484942&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;poster_path&#34;</span>: <span style="color:#e6db74">&#34;https://upload.wikimedia.org/wikipedia/en/a/ae/India%27s_Most_Wanted_poster.jpg&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wiki_link&#34;</span>: <span style="color:#e6db74">&#34;https://en.wikipedia.org/wiki/India%27s_Most_Wanted_(film)&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_y&#34;</span>: <span style="color:#e6db74">&#34;India&#39;s Most Wanted&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;original_title&#34;</span>: <span style="color:#e6db74">&#34;India&#39;s Most Wanted&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;is_adult&#34;</span>: <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;year_of_release&#34;</span>: <span style="color:#e6db74">&#34;2019&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;runtime&#34;</span>: <span style="color:#e6db74">&#34;123&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;genres&#34;</span>: <span style="color:#e6db74">&#34;Action|Thriller&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_rating&#34;</span>: <span style="color:#ae81ff">4.4</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_votes&#34;</span>: <span style="color:#ae81ff">1449</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;story&#34;</span>: <span style="color:#e6db74">&#34;India&#39;s Most Wanted is a Bollywood action thriller film directed by Raj Kumar Gupta and starring Arjun Kapoor. The film is about tracking a terrorist in a secret mission and arresting him without firing bullets. It pays tribute to unsung heroes of our society.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;summary&#34;</span>: <span style="color:#e6db74">&#34;A group of intelligence officers embark on a top secret mission to track down a wanted international criminal.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;tagline&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;actors&#34;</span>: <span style="color:#e6db74">&#34;Arjun Kapoor|Sudev Nair|Rajesh Sharma|Prasanth|Santilal Mukherjee|&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wins_nominations&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;release_date&#34;</span>: <span style="color:#e6db74">&#34;24 May 2019 (USA)&#34;</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_x&#34;</span>: <span style="color:#e6db74">&#34;Yeh Hai India&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_id&#34;</span>: <span style="color:#e6db74">&#34;tt5525846&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;poster_path&#34;</span>: <span style="color:#e6db74">&#34;https://upload.wikimedia.org/wikipedia/en/thumb/d/db/Yeh_Hai_India_Official_Poster.jpg/220px-Yeh_Hai_India_Official_Poster.jpg&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wiki_link&#34;</span>: <span style="color:#e6db74">&#34;https://en.wikipedia.org/wiki/Yeh_Hai_India&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_y&#34;</span>: <span style="color:#e6db74">&#34;Yeh Hai India&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;original_title&#34;</span>: <span style="color:#e6db74">&#34;Yeh Hai India&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;is_adult&#34;</span>: <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;year_of_release&#34;</span>: <span style="color:#e6db74">&#34;2017&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;runtime&#34;</span>: <span style="color:#e6db74">&#34;128&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;genres&#34;</span>: <span style="color:#e6db74">&#34;Action|Adventure|Drama&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_rating&#34;</span>: <span style="color:#ae81ff">5.7</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_votes&#34;</span>: <span style="color:#ae81ff">169</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;story&#34;</span>: <span style="color:#e6db74">&#34;Yeh Hai India  follows the story of a 25 years old NRI  who is born and brought up in U.K and shares the same stereotype views of India  which is known for its vast population  pollution and poverty. However protagonist finds new development in media or probably an &#39;other side of same coin&#39; of India  which is also known for successful mars mission in first attempt  a nation which proudly holds title &#39;God of Cricket&#39; for Sachin Tendulkar  who is again an Indian and a nation which is known for its holy generosity with icons like Mother Teresa\&#34;.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;summary&#34;</span>: <span style="color:#e6db74">&#34;Yeh Hai India  follows the story of a 25 years old NRI  who is born and brought up in UK. He shares the same stereotypical views about India that most NRIs have and how his perception changes.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;tagline&#34;</span>: <span style="color:#e6db74">&#34;A Film for Every Indian&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;actors&#34;</span>: <span style="color:#e6db74">&#34;Gavie Chahal|Mohan Agashe|Mohan Joshi|Lom Harsh|&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wins_nominations&#34;</span>: <span style="color:#e6db74">&#34;2 wins &amp; 1 nomination&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;release_date&#34;</span>: <span style="color:#e6db74">&#34;24 May 2019 (India)&#34;</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_x&#34;</span>: <span style="color:#e6db74">&#34;Kabir Singh&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_id&#34;</span>: <span style="color:#e6db74">&#34;tt8983202&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;poster_path&#34;</span>: <span style="color:#e6db74">&#34;https://upload.wikimedia.org/wikipedia/en/thumb/d/dc/Kabir_Singh.jpg/220px-Kabir_Singh.jpg&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wiki_link&#34;</span>: <span style="color:#e6db74">&#34;https://en.wikipedia.org/wiki/Kabir_Singh&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_y&#34;</span>: <span style="color:#e6db74">&#34;Kabir Singh&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;original_title&#34;</span>: <span style="color:#e6db74">&#34;Kabir Singh&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;is_adult&#34;</span>: <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;year_of_release&#34;</span>: <span style="color:#e6db74">&#34;2019&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;runtime&#34;</span>: <span style="color:#e6db74">&#34;173&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;genres&#34;</span>: <span style="color:#e6db74">&#34;Drama|Romance&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_rating&#34;</span>: <span style="color:#ae81ff">7.2</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_votes&#34;</span>: <span style="color:#ae81ff">20535</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;story&#34;</span>: <span style="color:#e6db74">&#34;This Sandeep Vanga directorial is a remake of the 2017 Telugu movie Arjun Reddy. The plot revolves around an alcoholic surgeon battling temper issues. Things get worse as he watches the love of his life marry another man. High on emotions coupled with impressive action the film promises an intense watch.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;summary&#34;</span>: <span style="color:#e6db74">&#34;Kabir Singh is a remake of a Telugu movie Arjun Reddy (2017)  where a short-tempered house surgeon gets used to drugs and drinks when his girlfriend is forced to marry another person.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;tagline&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;actors&#34;</span>: <span style="color:#e6db74">&#34;Shahid Kapoor|Kiara Advani|Soham Majumdar|Arjan Bajwa|Suresh Oberoi|Kamini Kaushal|Adil Hussain|Nikita Dutta|Amit Sharma|Anurag Arora|Dolly Mattoo|Aanchal Chauhan|Suparna Marwah|Swati Seth|&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wins_nominations&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;release_date&#34;</span>: <span style="color:#e6db74">&#34;20 June 2019 (USA)&#34;</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_x&#34;</span>: <span style="color:#e6db74">&#34;Article 15 (film)&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_id&#34;</span>: <span style="color:#e6db74">&#34;tt10324144&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;poster_path&#34;</span>: <span style="color:#e6db74">&#34;https://upload.wikimedia.org/wikipedia/en/thumb/1/11/Article_15_Poster.jpg/220px-Article_15_Poster.jpg&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wiki_link&#34;</span>: <span style="color:#e6db74">&#34;https://en.wikipedia.org/wiki/Article_15_(film)&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_y&#34;</span>: <span style="color:#e6db74">&#34;Article 15&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;original_title&#34;</span>: <span style="color:#e6db74">&#34;Article 15&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;is_adult&#34;</span>: <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;year_of_release&#34;</span>: <span style="color:#e6db74">&#34;2019&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;runtime&#34;</span>: <span style="color:#e6db74">&#34;130&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;genres&#34;</span>: <span style="color:#e6db74">&#34;Crime|Drama&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_rating&#34;</span>: <span style="color:#ae81ff">8.3</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_votes&#34;</span>: <span style="color:#ae81ff">13417</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;story&#34;</span>: <span style="color:#e6db74">&#34;In the rural heartlands of India  an upright police officer sets out on a crusade against violent caste-based crimes and discrimination.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;summary&#34;</span>: <span style="color:#e6db74">&#34;In the rural heartlands of India  an upright police officer sets out on a crusade against violent caste-based crimes and discrimination.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;tagline&#34;</span>: <span style="color:#e6db74">&#34;Farq Bahut Kar Liya| Ab Farq Laayenge.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;actors&#34;</span>: <span style="color:#e6db74">&#34;Ayushmann Khurrana|Nassar|Manoj Pahwa|Kumud Mishra|Isha Talwar|Sayani Gupta|Mohammed Zeeshan Ayyub|Subhrajyoti Barat|Sushil Pandey|Aakash Dabhade|Ashish Verma|Ronjini Chakraborty|Veen|Sumbul Touqueer|&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wins_nominations&#34;</span>: <span style="color:#e6db74">&#34;1 win&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;release_date&#34;</span>: <span style="color:#e6db74">&#34;28 June 2019 (USA)&#34;</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_x&#34;</span>: <span style="color:#e6db74">&#34;One Day: Justice Delivered&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_id&#34;</span>: <span style="color:#e6db74">&#34;tt8130558&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;poster_path&#34;</span>: <span style="color:#e6db74">&#34;https://upload.wikimedia.org/wikipedia/en/f/f7/One_Day-_Justice_Delivered.jpg&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wiki_link&#34;</span>: <span style="color:#e6db74">&#34;https://en.wikipedia.org/wiki/One_Day:_Justice_Delivered&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_y&#34;</span>: <span style="color:#e6db74">&#34;One Day: Justice Delivered&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;original_title&#34;</span>: <span style="color:#e6db74">&#34;One Day: Justice Delivered&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;is_adult&#34;</span>: <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;year_of_release&#34;</span>: <span style="color:#e6db74">&#34;2019&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;runtime&#34;</span>: <span style="color:#e6db74">&#34;124&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;genres&#34;</span>: <span style="color:#e6db74">&#34;Action|Crime|Thriller&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_rating&#34;</span>: <span style="color:#ae81ff">6.8</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_votes&#34;</span>: <span style="color:#ae81ff">590</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;story&#34;</span>: <span style="color:#e6db74">&#34;A Crime Branch Special Officer Investigates the Serial disappearance of high profile individuals in a state capital.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;summary&#34;</span>: <span style="color:#e6db74">&#34;A Crime Branch Special Officer Investigates the Serial disappearance of high profile individuals in a state capital.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;tagline&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;actors&#34;</span>: <span style="color:#e6db74">&#34;Anupam Kher|Kumud Mishra|Esha Gupta|Zakir Hussain|Rajesh Sharma|Murli Sharma|Deepshika Nagpal|&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wins_nominations&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;release_date&#34;</span>: <span style="color:#e6db74">&#34;5 July 2019 (India)&#34;</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_x&#34;</span>: <span style="color:#e6db74">&#34;Super 30 (film)&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_id&#34;</span>: <span style="color:#e6db74">&#34;tt7485048&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;poster_path&#34;</span>: <span style="color:#e6db74">&#34;https://upload.wikimedia.org/wikipedia/en/thumb/2/29/Super_30_The_Film.jpg/220px-Super_30_The_Film.jpg&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wiki_link&#34;</span>: <span style="color:#e6db74">&#34;https://en.wikipedia.org/wiki/Super_30_(film)&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_y&#34;</span>: <span style="color:#e6db74">&#34;Super 30&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;original_title&#34;</span>: <span style="color:#e6db74">&#34;Super 30&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;is_adult&#34;</span>: <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;year_of_release&#34;</span>: <span style="color:#e6db74">&#34;2019&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;runtime&#34;</span>: <span style="color:#e6db74">&#34;154&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;genres&#34;</span>: <span style="color:#e6db74">&#34;Biography|Drama&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_rating&#34;</span>: <span style="color:#ae81ff">8.2</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_votes&#34;</span>: <span style="color:#ae81ff">13972</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;story&#34;</span>: <span style="color:#e6db74">&#34;Anand Kumar  a Mathematics genius from a modest family in Bihar who is made to believe that only a King&#39;s son can become a king is on a mission to prove that even the poor man can create some of the world&#39;s most genius minds. He starts a training program named &#39;Super 30&#39; to help 30 IIT aspirants crack the entrance test and make them highly successful professionals.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;summary&#34;</span>: <span style="color:#e6db74">&#34;Based on life of Patna-based mathematician Anand Kumar who runs the famed Super 30 program for IIT aspirants in Patna.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;tagline&#34;</span>: <span style="color:#e6db74">&#34;Inspired by the Life of Anand Kumar &amp; His Students&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;actors&#34;</span>: <span style="color:#e6db74">&#34;Hrithik Roshan|Mrunal Thakur|Nandish Singh|Virendra Saxena|Sadhana Singh|Aditya Srivastava|Sanket Deshpande|Pankaj Tripathi|Vaibhav Gupta|Ali Haji|Rajesh Sharma|Deepali Kumar|Chittaranjan Giri|Ganesh Kumar|&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wins_nominations&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;release_date&#34;</span>: <span style="color:#e6db74">&#34;12 July 2019 (USA)&#34;</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_x&#34;</span>: <span style="color:#e6db74">&#34;Batla House&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_id&#34;</span>: <span style="color:#e6db74">&#34;tt8869978&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;poster_path&#34;</span>: <span style="color:#e6db74">&#34;https://upload.wikimedia.org/wikipedia/en/e/ed/Batla_House_poster.jpg&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wiki_link&#34;</span>: <span style="color:#e6db74">&#34;https://en.wikipedia.org/wiki/Batla_House&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_y&#34;</span>: <span style="color:#e6db74">&#34;Batla House&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;original_title&#34;</span>: <span style="color:#e6db74">&#34;Batla House&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;is_adult&#34;</span>: <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;year_of_release&#34;</span>: <span style="color:#e6db74">&#34;2019&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;runtime&#34;</span>: <span style="color:#e6db74">&#34;146&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;genres&#34;</span>: <span style="color:#e6db74">&#34;Action|Drama|Thriller&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_rating&#34;</span>: <span style="color:#ae81ff">7.3</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_votes&#34;</span>: <span style="color:#ae81ff">5556</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;story&#34;</span>: <span style="color:#e6db74">&#34;This action thriller is based on the real-life incident of &#39;Batla House Encounter&#39;  officially known as Operation Batla House  to the silver screen. The incident took place on September 19  2008  against Indian Mujahideen (IM) terrorists in Batla House locality in Jamia Nagar  Delhi.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;summary&#34;</span>: <span style="color:#e6db74">&#34;After a deadly encounter  a police officer works to prove that the police acted lawfully.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;tagline&#34;</span>: <span style="color:#e6db74">&#34;The Story of India&#39;s Most Decorated / Controversial Cop&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;actors&#34;</span>: <span style="color:#e6db74">&#34;John Abraham|Nora Fatehi|Mrunal Thakur|Rajesh Sharma|Ravi Kishan|Sonam Arora|Sahidur Rahaman|Manish Chaudhary|Anil Rastogi|Kranti Prakash Jha|Amruta Sant|Anil Khopkar|Aditi Gulati|Jitendra Trehan|&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wins_nominations&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;release_date&#34;</span>: <span style="color:#e6db74">&#34;15 August 2019 (USA)&#34;</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_x&#34;</span>: <span style="color:#e6db74">&#34;Mission Mangal&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_id&#34;</span>: <span style="color:#e6db74">&#34;tt9248972&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;poster_path&#34;</span>: <span style="color:#e6db74">&#34;https://upload.wikimedia.org/wikipedia/en/thumb/b/b7/Mission_Mangal.jpg/220px-Mission_Mangal.jpg&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wiki_link&#34;</span>: <span style="color:#e6db74">&#34;https://en.wikipedia.org/wiki/Mission_Mangal&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;title_y&#34;</span>: <span style="color:#e6db74">&#34;Mission Mangal&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;original_title&#34;</span>: <span style="color:#e6db74">&#34;Mission Mangal&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;is_adult&#34;</span>: <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;year_of_release&#34;</span>: <span style="color:#e6db74">&#34;2019&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;runtime&#34;</span>: <span style="color:#e6db74">&#34;130&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;genres&#34;</span>: <span style="color:#e6db74">&#34;Drama|History&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_rating&#34;</span>: <span style="color:#ae81ff">6.5</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;imdb_votes&#34;</span>: <span style="color:#ae81ff">7165</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;story&#34;</span>: <span style="color:#e6db74">&#34;Based on true events of the Indian Space Research Organisation (ISRO) successfully launching the Mars Orbiter Mission (Mangalyaan)  making it the least expensive mission to Mars.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;summary&#34;</span>: <span style="color:#e6db74">&#34;Based on true events of the Indian Space Research Organisation (ISRO) successfully launching the Mars Orbiter Mission (Mangalyaan)  making it the least expensive mission to Mars.&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;tagline&#34;</span>: <span style="color:#e6db74">&#34;This Independence Day...The Sky is Not the Limit&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;actors&#34;</span>: <span style="color:#e6db74">&#34;Akshay Kumar|Vidya Balan|Nithya Menon|Taapsee Pannu|Sonakshi Sinha|Kirti Kulhari|H.G. Dattatreya|Sharman Joshi|Sanjay Kapoor|Dalip Tahil|Vikram Gokhale|Mohammed Zeeshan Ayyub|Purab Kohli|&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;wins_nominations&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;release_date&#34;</span>: <span style="color:#e6db74">&#34;15 August 2019 (USA)&#34;</span>
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>]
</span></span></code></pre></div><p>Install <code>jq</code> on your linux machine and hit below command</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cat movies.json | <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>jq -c <span style="color:#e6db74">&#39;.[] | {&#34;index&#34;: {&#34;_index&#34;: &#34;movies&#34;, &#34;_id&#34;: .id}}, .&#39;</span> &gt; nd-movies.json
</span></span></code></pre></div><p>Verify newly created <code>nd-movies.json</code> file.</p>
]]></content:encoded>
    </item>
    <item>
      <title>Setup &amp; Observe Kubernetes cluster</title>
      <link>https://ashish.one/talks/setup_and_observe_kubernetes/</link>
      <pubDate>Thu, 28 Mar 2024 21:41:03 +0530</pubDate>
      <guid>https://ashish.one/talks/setup_and_observe_kubernetes/</guid>
      <description>&lt;h1 id=&#34;introduction&#34;&gt;Introduction&lt;/h1&gt;
&lt;p&gt;In this gist we will quickly spin a sample Kubernetes cluster and deploying the nginx pod. Additionally, we will implement monitoring using Elastic.&lt;/p&gt;
&lt;h1 id=&#34;setup-k8s-cluster&#34;&gt;Setup K8s cluster&lt;/h1&gt;
&lt;h2 id=&#34;cluster-architecture&#34;&gt;Cluster architecture&lt;/h2&gt;
&lt;p&gt;3 Node cluster&lt;/p&gt;
&lt;p&gt;Machine - Centos7, 4GB RAM&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;kube1.local  - Control plane node&lt;/li&gt;
&lt;li&gt;kube2.local - worker node&lt;/li&gt;
&lt;li&gt;kube3.local - worker node&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here I am setting hostname &lt;code&gt;kube1.local&lt;/code&gt;, &lt;code&gt;kube2.local&lt;/code&gt;, &lt;code&gt;kube3.local&lt;/code&gt;.  Login into all of the servers and perform below command on all three nodes.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h1 id="introduction">Introduction</h1>
<p>In this gist we will quickly spin a sample Kubernetes cluster and deploying the nginx pod. Additionally, we will implement monitoring using Elastic.</p>
<h1 id="setup-k8s-cluster">Setup K8s cluster</h1>
<h2 id="cluster-architecture">Cluster architecture</h2>
<p>3 Node cluster</p>
<p>Machine - Centos7, 4GB RAM</p>
<ol>
<li>kube1.local  - Control plane node</li>
<li>kube2.local - worker node</li>
<li>kube3.local - worker node</li>
</ol>
<p>Here I am setting hostname <code>kube1.local</code>, <code>kube2.local</code>, <code>kube3.local</code>.  Login into all of the servers and perform below command on all three nodes.</p>
<h2 id="swap-off">Swap off</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>sudo swapoff -a
</span></span></code></pre></div><h2 id="install-docker">Install docker</h2>
<p>You can refer <a href="https://docs.docker.com/engine/install/centos/">docker documentation</a> but here are the quick steps:</p>
<h2 id="contanerd-runtime">Contanerd runtime</h2>
<p>kubeadm automatically tries to detect an installed container runtime by scanning through a list of known endpoints.</p>
<p>Verify if containerd is running or not</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>ps -ef | grep containerd
</span></span></code></pre></div><p>In my system containerd was running. <a href="https://github.com/containerd/containerd/blob/main/docs/getting-started.md">Install containerd</a> if it is not installed.</p>
<p>Change below cofing to remove <code>cri</code> from <code>disable_plugins</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>sudo vim /etc/containerd/config.toml
</span></span><span style="display:flex;"><span><span style="color:#75715e">#disabled_plugins = [&#34;cri&#34;]</span>
</span></span><span style="display:flex;"><span>disabled_plugins <span style="color:#f92672">=</span> <span style="color:#f92672">[]</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>sudo systemctl restart containerd
</span></span></code></pre></div><h2 id="install-kubeadm-kubelet--kubectl">Install kubeadm, kubelet &amp; kubectl</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cat <span style="color:#e6db74">&lt;&lt;EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">[kubernetes]
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">name=Kubernetes
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">baseurl=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">enabled=1
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">gpgcheck=1
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">gpgkey=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/repodata/repomd.xml.key
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">EOF</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Set SELinux in permissive mode (effectively disabling it)</span>
</span></span><span style="display:flex;"><span>sudo setenforce <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>sudo sed -i <span style="color:#e6db74">&#39;s/^SELINUX=enforcing$/SELINUX=permissive/&#39;</span> /etc/selinux/config
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>sudo yum install -y kubelet kubeadm kubectl --disableexcludes<span style="color:#f92672">=</span>kubernetes
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>sudo systemctl enable --now kubelet
</span></span></code></pre></div><p>Make sure you install same version on all of the nodes. In my case i am installing <code>v1.28</code>.</p>
<p>Need to install all three packages on all nodes</p>
<p><strong>Kubeadm</strong> - Use to bootstrap the cluster</p>
<p><strong>Kubelet</strong> - Will run all over the machin and take care of pods and container (General operation like stop / start / modify)</p>
<p><strong>Kubectl</strong> - command line utility to talk with kubernetes APIs</p>
<h2 id="on-control-plane-node-only-kube1local">On control plane node only (kube1.local)</h2>
<p>Initialise kubeadm</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>kubeadm init
</span></span></code></pre></div><p>On success, It will print the below <code>join</code> command, which we will use to join any machine in the cluster.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>kubeadm join control_plane_ip:6443 --token tlif0t.jq7r1nvdmltre7m3 --discovery-token-ca-cert-hash sha256:02eb1a7f249b2f2a2b8db2b8fef9b5564ac3db9d42da39db71c23c06df5cecb8
</span></span></code></pre></div><p>Save this command. We need to execute this command on every worker node to join the cluster.</p>
<h2 id="on-worker-node-only-kube2local-kube3local">On worker node only (kube2.local, kube3.local)</h2>
<p>Perform join command.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>kubeadm join control_plane_ip:6443 --token tlif0t.jq7r1nvdmltre7m3 --discovery-token-ca-cert-hash sha256:02eb1a7f249b2f2a2b8db2b8fef9b5564ac3db9d42da39db71c23c06df5cecb8
</span></span></code></pre></div><p>You should see the message - “This node has joined the cluster” with addition details.</p>
<h2 id="verify-cluster-kube1local">Verify cluster (kube1.local)</h2>
<p>Enable <code>kubectl</code> to run from non root user.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>mkdir -p $HOME/.kube
</span></span><span style="display:flex;"><span>sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
</span></span><span style="display:flex;"><span>sudo chown <span style="color:#66d9ef">$(</span>id -u<span style="color:#66d9ef">)</span>:<span style="color:#66d9ef">$(</span>id -g<span style="color:#66d9ef">)</span> $HOME/.kube/config
</span></span></code></pre></div><p>List nodes</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>kubectl get nodes
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>NAME          STATUS   ROLES           AGE     VERSION
</span></span><span style="display:flex;"><span>kube1.local   Ready    control-plane   199d    v1.28.1
</span></span><span style="display:flex;"><span>kube2.local   Ready    &lt;none&gt;          8m22s   v1.28.8
</span></span><span style="display:flex;"><span>kube3.local   Ready    &lt;none&gt;          199d    v1.28.1
</span></span></code></pre></div><p>Our cluster is up and running.</p>
<h1 id="deploy-nginx-kube1local">Deploy Nginx (kube1.local)</h1>
<p>Create Nginx deployment</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cat <span style="color:#e6db74">&lt;&lt;EOF | kubectl apply -f -
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">apiVersion: apps/v1
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">kind: Deployment
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">metadata:
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  name: nginx-deployment
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">spec:
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  selector:
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    matchLabels:
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      app: nginx
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  replicas: 2
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  template:
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    metadata:
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      labels:
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">        app: nginx
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    spec:
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      containers:
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      - name: nginx
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">        image: nginx:latest
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">        ports:
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">        - containerPort: 80
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">EOF</span>
</span></span></code></pre></div><p>Expose the Nginx deployment on a NodePort 32000</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cat <span style="color:#e6db74">&lt;&lt;EOF | kubectl apply -f -
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">apiVersion: v1
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">kind: Service
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">metadata:
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  name: nginx-service
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">spec:
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  selector:
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    app: nginx
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  type: NodePort
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  ports:
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    - port: 80
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      targetPort: 80
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      nodePort: 32000
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">EOF</span>
</span></span></code></pre></div><p>Verify pod is running</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>Kubectl get pods
</span></span></code></pre></div><p>Just visit on browser - http://external_id:32000.</p>
<p>You should able to see the nginx’s default page.</p>
<h1 id="setup-observability-with-elastic">Setup Observability with Elastic</h1>
<h2 id="enable-kube-state-matrics-kube1local">Enable kube-state-matrics (kube1.local)</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>git clone https://github.com/kubernetes/kube-state-metrics
</span></span><span style="display:flex;"><span>kubectl apply -f kube-state-metrics/examples/standard/
</span></span></code></pre></div><h2 id="verify-endpoint">Verify endpoint</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>kubectl port-forward svc/kube-state-metrics -n kube-system 8080:8080
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">#login to anoter tab and hit</span>
</span></span><span style="display:flex;"><span>curl localhost:8080/metrics
</span></span></code></pre></div><p>It should return all metrics.</p>
<h2 id="monitoring-using-elastic-cloud">Monitoring using Elastic cloud</h2>
<p>You can follow detailed doc - <a href="https://www.elastic.co/getting-started/observability/monitor-kubernetes-clusters">https://www.elastic.co/getting-started/observability/monitor-kubernetes-clusters</a></p>
<p>Blog - <a href="https://www.elastic.co/blog/kubernetes-cluster-metrics-logs-monitoring">https://www.elastic.co/blog/kubernetes-cluster-metrics-logs-monitoring</a></p>
<h1 id="reference-talk">Reference talk</h1>
<p>Bring logs, metrics, and traces from your Kubernetes cluster and the workloads running on it into a single, unified solution. Elastic observability gives better visibility on your kubernetes ecosystem where you can monitor your pods, services, workload etc. Use a centrally managed Elastic Agent to gain visibility into your Kubernetes deployments on EKS, AKS, GKE or self-managed clusters.</p>
<h2 id="talk-video">Talk Video</h2>


    
    <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/8qOt_gYjwcw?autoplay=0&controls=1&end=0&loop=0&mute=0&start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"
      ></iframe>
    </div>

]]></content:encoded>
    </item>
    <item>
      <title>Elasticsearch Query Language (ES|QL)</title>
      <link>https://ashish.one/talks/esql/</link>
      <pubDate>Thu, 01 Feb 2024 10:54:52 +0530</pubDate>
      <guid>https://ashish.one/talks/esql/</guid>
      <description>&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://www.elastic.co/guide/en/elasticsearch/reference/current/esql.html&#34;&gt;ES|QL&lt;/a&gt; is a new query language for Elasticsearch. It is the unified language for all kinds of use cases like simple queries, aggregations, performing correlations, finding logs, etc. It provides simple easy syntax to perform complex queries. If you come from SQL background, You going to find this very handy.&lt;/p&gt;
&lt;p&gt;It is a piped separated langugage with a combination of &lt;a href=&#34;https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-commands.html#esql-source-commands&#34;&gt;source commands&lt;/a&gt; and &lt;a href=&#34;https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-commands.html#esql-processing-commands&#34;&gt;process&lt;/a&gt; commands. The Elasticsearch Query Language (ES|QL) makes use of &amp;ldquo;pipes&amp;rdquo; (|) to manipulate and transform data in a step-by-step fashion. This means output of the first step will go as an input for second step.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h2 id="introduction">Introduction</h2>
<p><a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/esql.html">ES|QL</a> is a new query language for Elasticsearch. It is the unified language for all kinds of use cases like simple queries, aggregations, performing correlations, finding logs, etc. It provides simple easy syntax to perform complex queries. If you come from SQL background, You going to find this very handy.</p>
<p>It is a piped separated langugage with a combination of <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-commands.html#esql-source-commands">source commands</a> and <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-commands.html#esql-processing-commands">process</a> commands. The Elasticsearch Query Language (ES|QL) makes use of &ldquo;pipes&rdquo; (|) to manipulate and transform data in a step-by-step fashion. This means output of the first step will go as an input for second step.</p>
<p>ES|QL is more than langugage. The execution engine is developed by considering performance in mind. Here ES|QL is not going to convert into Query DSL instead it will be directly executed within Elasticsearch. It operates on blocks at a time instead of per row, targets vectorization and cache locality, and embraces specialization and multi-threading.</p>
<blockquote>
<p>ES|QL - Filter, Transform and Analyze</p>
</blockquote>
<h2 id="example">Example</h2>
<p>Below is a few examples of ES|QL. I am considering you have an Elasticsearch and kibana is <a href="https://www.elastic.co/search-labs/tutorials/install-elasticsearch">installed</a> and running. Please <a href="https://www.elastic.co/guide/en/kibana/current/get-started.html#gs-get-data-into-kibana">import the sample dataset (Sample web logs)</a> from kibana. Navigate in side menu  -&gt; <code>Management</code> -&gt; <code>Dev Tools</code>  to perform the below query.</p>
<h3 id="source-commands">Source commands</h3>
<h4 id="from">FROM</h4>
<pre tabindex="0"><code># Format

POST /_query?format=csv
{
  &#34;query&#34;: &#34;&#34;&#34;
    from kibana_sample_data_logs
  &#34;&#34;&#34;
}
</code></pre><h4 id="row">ROW</h4>
<pre tabindex="0"><code>POST _query?format=txt
{
  &#34;query&#34;:&#34;&#34;&#34;
    row a = &#34;Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1&#34;
    | dissect a &#34;%{browser}/%{version}&#34;
    | keep browser
  &#34;&#34;&#34;
}
</code></pre><h4 id="show">SHOW</h4>
<pre tabindex="0"><code>POST /_query?format=txt
{
  &#34;query&#34;: &#34;&#34;&#34;
    show info
  &#34;&#34;&#34;
}
</code></pre><h3 id="processing-commands">Processing commands</h3>
<h4 id="keep">keep</h4>
<pre tabindex="0"><code>POST _query?format=txt
{
  &#34;query&#34;: &#34;&#34;&#34;
    from kibana_sample_data_logs
    | keep @timestamp, clientip, host, tags, bytes
  &#34;&#34;&#34;
}
</code></pre><h4 id="where-limit-sort">where, limit, sort</h4>
<pre tabindex="0"><code>POST _query?format=txt
{
  &#34;query&#34;: &#34;&#34;&#34;
    from kibana_sample_data_logs
    | keep @timestamp, clientip, host, tags, bytes
    | where bytes &gt; 1000
    | sort bytes desc
    | limit 5
  &#34;&#34;&#34;
}
</code></pre><h4 id="like">like</h4>
<pre tabindex="0"><code>POST _query?format=txt
{
  &#34;query&#34;:&#34;&#34;&#34;
    FROM sample_data
    | where message like &#34;*error*&#34;
  &#34;&#34;&#34;
}
</code></pre><h4 id="grok-statsby">GROK, STATS&hellip;BY</h4>
<pre tabindex="0"><code>POST _query?format=txt
{
  &#34;query&#34;:&#34;&#34;&#34;
    from kibana_sample_data_logs
    | grok agent &#34;%{WORD:browser}/%{NUMBER:version}&#34;
    | keep browser, version, @timestamp
  &#34;&#34;&#34;
}

POST _query?format=txt
{
  &#34;query&#34;:&#34;&#34;&#34;
    from kibana_sample_data_logs
    | grok agent &#34;%{WORD:browser}/%{NUMBER:version}&#34;
    | keep browser, version, @timestamp
    | stats count(*) by version
  &#34;&#34;&#34;
}
</code></pre><h4 id="dissect">DISSECT</h4>
<pre tabindex="0"><code>POST _query?format=txt
{
  &#34;query&#34;: &#34;&#34;&#34;
    from kibana_sample_data_logs 
    | dissect message &#34;%{ip} - - %{time} %{web_call} &#34;
    | keep ip, time, web_call
  &#34;&#34;&#34;
}
</code></pre><h4 id="eval">EVAL</h4>
<pre tabindex="0"><code>POST /_query?format=txt
{
  &#34;query&#34;: &#34;&#34;&#34;
    from kibana_sample_data_logs
    | eval t = replace(agent, &#34;Mozilla&#34;, &#34;Chrome&#34;)
    | eval l = length(agent)
    | dissect agent &#34;%{browser}/%{version} &#34;
    | eval lt = left(t, 6)
    | keep lt, browser, version, t, l
  &#34;&#34;&#34;
}
</code></pre><p>You can check more <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-functions-operators.html#esql-string-functions">string functions</a>.</p>
<h4 id="data-enrichment-enrich">Data enrichment (ENRICH)</h4>
<pre tabindex="0"><code>
# Create mappings

PUT lang
{
  &#34;mappings&#34;: {
    &#34;properties&#34;: {
      &#34;lang_id&#34;: {
        &#34;type&#34;: &#34;keyword&#34;
      },
      &#34;name&#34;: {
        &#34;type&#34;: &#34;keyword&#34;
      }
    }
  }
}

PUT devs
{
  &#34;mappings&#34;: {
    &#34;properties&#34;: {
      &#34;lang_id&#34;: {
        &#34;type&#34;: &#34;keyword&#34;
      },
      &#34;name&#34;: {
        &#34;type&#34;: &#34;keyword&#34;
      }
    }
  }
}

# Create index &#34;lang&#34;

PUT lang/_bulk
{ &#34;index&#34; : {}}
{ &#34;lang_id&#34;: &#34;1x&#34;, &#34;name&#34;: &#34;java&#34; }
{ &#34;index&#34; : {}}
{ &#34;lang_id&#34;: &#34;2x&#34;, &#34;name&#34;: &#34;php&#34; }
{ &#34;index&#34; : {}}
{ &#34;lang_id&#34;: &#34;3x&#34;, &#34;name&#34;: &#34;node&#34; }
{ &#34;index&#34; : {}}
{ &#34;lang_id&#34;: &#34;4x&#34;, &#34;name&#34;: &#34;python&#34; }
{ &#34;index&#34; : {}}
{ &#34;lang_id&#34;: &#34;5x&#34;, &#34;name&#34;: &#34;ruby&#34; }

# create index &#34;devs&#34;

PUT devs/_bulk
{ &#34;index&#34; : {}}
{ &#34;lang_id&#34;: &#34;5x&#34;, &#34;developer&#34;: &#34;bob&#34; }
{ &#34;index&#34; : {}}
{ &#34;lang_id&#34;: &#34;3x&#34;, &#34;developer&#34;: &#34;mark&#34; }
{ &#34;index&#34; : {}}
{ &#34;lang_id&#34;: &#34;1x&#34;, &#34;developer&#34;: &#34;max&#34; }
{ &#34;index&#34; : {}}
{ &#34;lang_id&#34;: &#34;2x&#34;, &#34;developer&#34;: &#34;david&#34; }
{ &#34;index&#34; : {}}
{ &#34;lang_id&#34;: &#34;4x&#34;, &#34;developer&#34;: &#34;ashish&#34; }


# Create enrich policy

PUT /_enrich/policy/dev_lang
{
  &#34;match&#34;: {
    &#34;indices&#34;: &#34;lang&#34;,
    &#34;match_field&#34;: &#34;lang_id&#34;,
    &#34;enrich_fields&#34;: [&#34;name&#34;]
  }
}

PUT /_enrich/policy/dev_lang/_execute?wait_for_completion=true

POST _query?format=txt
{
  &#34;query&#34;:&#34;&#34;&#34;
    from devs
    | keep lang_id, name, developer
    | enrich dev_lang on lang_id with name
  &#34;&#34;&#34;
}
</code></pre>]]></content:encoded>
    </item>
    <item>
      <title>Elasticsearch: Vector and Hybrid Search</title>
      <link>https://ashish.one/talks/vector-hybrid-search/</link>
      <pubDate>Tue, 29 Aug 2023 21:41:03 +0530</pubDate>
      <guid>https://ashish.one/talks/vector-hybrid-search/</guid>
      <description>&lt;h1 id=&#34;introduction&#34;&gt;Introduction&lt;/h1&gt;
&lt;p&gt;Search is not just traditional TF/IDF any more but the current trend of machine learning and models has opened another dimension for search.&lt;/p&gt;
&lt;p&gt;This talk gives an overview of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Classic&lt;/strong&gt; search and its limitations.&lt;/li&gt;
&lt;li&gt;What is a model and how can you use it.&lt;/li&gt;
&lt;li&gt;How to use vector search or hybrid search in Elasticsearch.&lt;/li&gt;
&lt;li&gt;Where OpenAI&amp;rsquo;s ChatGPT or similar LLMs come into play to with Elastic.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Check how to leverage &lt;a href=&#34;https://ashish.one/talks/chatgpt-elasticsearch/&#34;&gt;Leverage ChatGPT with Elasticsearch&lt;/a&gt;.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h1 id="introduction">Introduction</h1>
<p>Search is not just traditional TF/IDF any more but the current trend of machine learning and models has opened another dimension for search.</p>
<p>This talk gives an overview of:</p>
<ul>
<li><strong>Classic</strong> search and its limitations.</li>
<li>What is a model and how can you use it.</li>
<li>How to use vector search or hybrid search in Elasticsearch.</li>
<li>Where OpenAI&rsquo;s ChatGPT or similar LLMs come into play to with Elastic.</li>
</ul>
<p>Check how to leverage <a href="https://ashish.one/talks/chatgpt-elasticsearch/">Leverage ChatGPT with Elasticsearch</a>.</p>
<h2 id="talk-video">Talk Video</h2>


    
    <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/AljarsLZRW0?autoplay=0&controls=1&end=0&loop=0&mute=0&start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"
      ></iframe>
    </div>

]]></content:encoded>
    </item>
    <item>
      <title>Monitor Kubernetes cluster with Elastic</title>
      <link>https://ashish.one/talks/monitor_k8_elastic_observability/</link>
      <pubDate>Fri, 28 Jul 2023 21:41:03 +0530</pubDate>
      <guid>https://ashish.one/talks/monitor_k8_elastic_observability/</guid>
      <description>&lt;h1 id=&#34;introduction&#34;&gt;Introduction&lt;/h1&gt;
&lt;p&gt;Bring logs, metrics, and traces from your Kubernetes cluster and the workloads running on it into a single, unified solution. Elastic observability gives better visibility on your kubernetes ecosystem where you can monitor your pods, services, workload etc. Use a centrally managed Elastic Agent to gain visibility into your Kubernetes deployments on EKS, AKS, GKE or self-managed clusters.&lt;/p&gt;
&lt;h2 id=&#34;talk-video&#34;&gt;Talk Video&lt;/h2&gt;


    
    &lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
      &lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&#34; allowfullscreen=&#34;allowfullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/8qOt_gYjwcw?autoplay=0&amp;controls=1&amp;end=0&amp;loop=0&amp;mute=0&amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;
      &gt;&lt;/iframe&gt;
    &lt;/div&gt;</description>
      <content:encoded><![CDATA[<h1 id="introduction">Introduction</h1>
<p>Bring logs, metrics, and traces from your Kubernetes cluster and the workloads running on it into a single, unified solution. Elastic observability gives better visibility on your kubernetes ecosystem where you can monitor your pods, services, workload etc. Use a centrally managed Elastic Agent to gain visibility into your Kubernetes deployments on EKS, AKS, GKE or self-managed clusters.</p>
<h2 id="talk-video">Talk Video</h2>


    
    <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/8qOt_gYjwcw?autoplay=0&controls=1&end=0&loop=0&mute=0&start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"
      ></iframe>
    </div>

]]></content:encoded>
    </item>
    <item>
      <title>Workshop - Leverage ChatGPT with Elasticsearch</title>
      <link>https://ashish.one/talks/chatgpt-elasticsearch/</link>
      <pubDate>Fri, 21 Jul 2023 15:52:06 +0530</pubDate>
      <guid>https://ashish.one/talks/chatgpt-elasticsearch/</guid>
      <description>Connect ChatGPT to proprietary data stores using Elasticsearch</description>
      <content:encoded><![CDATA[<h1 id="objective">Objective</h1>
<p>In this hands-on workshop, We will learn how to connect ChatGPT to proprietary data stores using Elasticsearch and build question/answer capabilities for your data. In a demo, We will quickly convert your website, FAQ, or any documentation into prompt chat where your user can directly ask a question on your data.</p>
<h1 id="flow">Flow</h1>
<p><img loading="lazy" src="/img/talks/elasticsearch-chatgpt/flow.png" alt="ChatGPT with Elasticsearch"  />
</p>
<h1 id="prerequisites">Prerequisites</h1>
<ol>
<li>
<p>You have used ChatGPT :)</p>
</li>
<li>
<p>Good to have understanding around Elasticsearch (Not mandatory, Introduction will be cover)</p>
</li>
<li>
<p>System + Internet connection</p>
</li>
<li>
<p>OpenAI account with API key - Create new one from <a href="https://platform.openai.com/account/api-keys">https://platform.openai.com/account/api-keys</a>. Make sure it having <a href="https://platform.openai.com/account/usage">free credits</a>.</p>
</li>
</ol>
<h2 id="without-local-setup">Without local setup</h2>
<ol>
<li>
<p>Google account to use <a href="https://colab.research.google.com/">google Colab</a>.</p>
</li>
<li>
<p><a href="https://render.com/">Render</a> account.</p>
</li>
</ol>
<h2 id="local-setup">Local setup</h2>
<ol>
<li>
<p>Git - Install it from <a href="https://git-scm.com/downloads">https://git-scm.com/downloads</a></p>
</li>
<li>
<p>Docker - Good to have. Install it from <a href="https://docs.docker.com/engine/install/">https://docs.docker.com/engine/install/</a>.</p>
</li>
<li>
<p>Having basic python knowledge will be good.</p>
</li>
</ol>
<p>For a workshop we going to follow without local setup.</p>
<h1 id="1-setup-cluster">1. Setup cluster</h1>
<ol>
<li>
<p>Visit <a href="https://cloud.elastic.co">cloud.elastic.co</a> and signup.</p>
</li>
<li>
<p>Click on <em><strong>Create deployment</strong></em>. In the pop-up, you can change the settings or leave it default.</p>
</li>
<li>
<p>We need to add machine learning instance. For that, simply click on &ldquo;<em><strong>advance settings</strong></em>&rdquo; .</p>
</li>
<li>
<p>Go to <em><strong>&ldquo;Machine Learning instances&rdquo; -&gt; click on &ldquo;Add Capacity&rdquo;</strong></em> and select at least <strong>4GB</strong> ram capacity.</p>
</li>
<li>
<p>Finally click on &ldquo;<em><strong>Create deployment</strong></em>&rdquo;.</p>
</li>
<li>
<p>Download / Copy the deployment credentials.</p>
</li>
<li>
<p>Once deployment ready, click on &ldquo;Continue&rdquo; (or click on <em><strong>Open Kibana</strong></em>). It will redirect you on kibana dashboard.</p>
</li>
</ol>
<h1 id="2-deploy-model">2. Deploy Model</h1>
<h2 id="elser-model-by-elastic-recommended">ELSER Model by Elastic (Recommended)</h2>
<p>Go to the kibana panel. Navigate to <em><strong>Menu -&gt; Machine Learning</strong></em> (In <em>Analytics</em> section). In left menu, Click on <em><strong>Trained Models</strong></em> (In <em>Model Management</em> Section).</p>
<ol>
<li>ELSER can be found in the list of trained models.</li>
<li>Click the <em><strong>Download model</strong></em> button under <em><strong>Actions</strong></em>.</li>
<li>After the download is finished, start the deployment by clicking the <em><strong>Start deployment</strong></em> button.</li>
<li>Provide a deployment ID, select the priority, and set the number of allocations and threads per allocation values.</li>
<li>Click <em><strong>Start</strong></em>.</li>
</ol>
<h2 id="third-party-model">Third party model</h2>
<p>We are going to use <a href="https://huggingface.co/sentence-transformers/all-distilroberta-v1">all-distilroberta-v1</a> model hosted on a hugging face. Lets import on an elastic cluster using eland.</p>
<p><strong>Get your credentials ready</strong></p>
<ul>
<li><code>cloud_id</code> : Visit “<em><strong><a href="https://cloud.elastic.co">cloud.elastic.co</a></strong></em>” -&gt; Navigate to your deployment and click on “<em><strong>manage</strong></em>”. Simply copy Cloud ID and save it.</li>
<li><code>cloud_user</code>: <code>elastic</code></li>
<li><code>cloud_password</code>: You will get it from step 1.6. If you forget to save, Simply click on <em><strong>“Action” -&gt; “Reset password”</strong></em>. (Username will be <code>elastic</code> only)</li>
<li><code>hf_model_id</code>: <code>sentence-transformers/all-distilroberta-v1</code> (Go to model <a href="https://huggingface.co/sentence-transformers/all-distilroberta-v1">page</a> on huggingface &amp; copy the ID <code>sentence-transformers/all-distilroberta-v1</code>)</li>
</ul>
<p>Now there is two way, You can upload the model using <code>docker</code> as well as <code>Google colab</code>.</p>
<h3 id="using-google-colab-recommended">Using Google Colab (Recommended)</h3>
<p>Simply click on below link. It will open ready made notebook. You just need to click on <code>play</code> button to run notebood.</p>
<p><a href="https://colab.research.google.com/github/ashishtiwari1993/elasticsearch-chatgpt/blob/main/load_model_eland.ipynb"><img loading="lazy" src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"  />
</a></p>
<h3 id="using-docker">Using Docker</h3>
<ol start="2">
<li>
<p>We’re going to use docker for import model to the elastic cluster</p>
<ol>
<li>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span> git clone https://github.com/elastic/eland.git 
</span></span><span style="display:flex;"><span> cd eland
</span></span></code></pre></div></li>
<li>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span> docker build -t elastic/eland .
</span></span></code></pre></div></li>
<li>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span> docker run -it --rm elastic/eland eland_import_hub_model <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>     --cloud-id &lt;cloud_id&gt; <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>     -u elastic -p &lt;elastic_cloud_password&gt; <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>     --hub-model-id sentence-transformers/all-distilroberta-v1 <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>     --task-type text_embedding <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>     --start
</span></span></code></pre></div></li>
<li>
<p>Let&rsquo;s wait till the model gets uploaded without any error.</p>
</li>
<li>
<p>Exit from <code>eland</code> folder.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cd ..
</span></span></code></pre></div></li>
</ol>
</li>
</ol>
<h3 id="verify-uploaded-model">Verify uploaded model</h3>
<p>Go to the kibana panel. Navigate to <em><strong>Menu -&gt; Machine Learning (In <code>Analytics</code> section)</strong></em>. In left menu, Click on <em><strong>Trained Models</strong></em>(<code>Model Management</code> Section). You must see your model here in the “<em><strong>Started</strong></em>” state.</p>
<p>In case if a warning message is displayed at the top of the page that says <em><strong>ML job and trained model synchronization required</strong></em>. Follow the link to <em><strong>Synchronize your jobs and trained models.</strong></em> Then click <em><strong>Synchronize</strong></em>.</p>
<h1 id="3-crawling-private-data">3. Crawling private data</h1>
<ol>
<li>Click on <em><strong>Menu -&gt; Enterprise Search -&gt; “Create an Elasticsearch index”</strong></em> button</li>
<li>Click on <em><strong>Web crawler</strong></em>.</li>
<li>Add index name (It will add prefix <em><strong>search</strong></em>) and  hit “<em><strong>Create index</strong></em>”. In my case index name is (search-ashish.one)</li>
<li>Go to “<em><strong>Pipelines</strong></em>” to create a pipeline.</li>
<li>Click “<em><strong>Copy and customize</strong></em>” in the Ingest Pipeline Box.</li>
<li>Click “<em><strong>Add Inference Pipeline</strong></em>” in the Machine Learning Inference Pipelines box.</li>
<li>Give the unique pipeline name e.g. “<em><strong>ml-inference-ashish-one</strong></em>”</li>
<li>Select a trained ML Model from the dropdown “<em><strong>sentence-transformers__all-distilroberta-v1</strong></em>” (For ELSER choose &ldquo;<em><strong>.elser_model_1</strong></em>&rdquo;)</li>
<li>Select “<em><strong>title</strong></em>” as the Source field and set “<em><strong>title-vector</strong></em>” as a destination. You can specify your own destination field name. (In case of ELSER, just select the &ldquo;<em><strong>Source</strong></em>&rdquo; field e.g <em>title, body_content</em>)</li>
<li>Let&rsquo;s click on “<em><strong>Continue</strong></em>” and move to the Test(Optional) tab.  Click on “<em><strong>Continue</strong></em>” again.</li>
<li>At the Review stage let&rsquo;s click on “<em><strong>Create pipeline</strong></em>”.</li>
<li>(Skip this for <em><strong>ELSER</strong></em>) Go to <em><strong>Menu -&gt; Management -&gt; Dev Tools</strong></em>. Let&rsquo;s create a mapping</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>POST &lt;index_name&gt;/_mapping
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;properties&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;&lt;vector_field_name&gt;&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;type&#34;</span>: <span style="color:#e6db74">&#34;dense_vector&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;dims&#34;</span>: 768,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;index&#34;</span>: true,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;similarity&#34;</span>: <span style="color:#e6db74">&#34;dot_product&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>In my case mapping will be:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>POST search-ashish.one/_mapping
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;properties&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;title-vector&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;type&#34;</span>: <span style="color:#e6db74">&#34;dense_vector&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;dims&#34;</span>: 768,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;index&#34;</span>: true,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;similarity&#34;</span>: <span style="color:#e6db74">&#34;dot_product&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>Paste above query in <code>cosole</code> and hit on play button.</p>
<ol start="13">
<li>Go to <em><strong>Enterprise search -&gt; indices -&gt; your_index_name -&gt; Manage Domains</strong></em>. Enter the domain (e.g. <a href="https://ashish.one">https://ashish.one</a>. You can add your own domain) to crawl and hit “<em><strong>Validate Domain</strong></em>”.</li>
<li>If everything is fine, simply click on “<em><strong>Add domain</strong></em>” and start crawling by click on <em><strong>Crawl -&gt; Crawl all domains on this index</strong></em>.</li>
<li>Go to <em><strong>Enterprise Search -&gt; Indices</strong></em>. You should see your index name.</li>
</ol>
<h1 id="4-setup-interface">4. Setup Interface</h1>
<p>** Get your credentials ready **</p>
<ol>
<li><code>cloud_id</code> : Visit “<em><strong><a href="https://cloud.elastic.co">cloud.elastic.co</a></strong></em>” -&gt; Navigate to your deployment and click on “<em><strong>manage</strong></em>”. Simply copy Cloud ID and save it.</li>
<li><code>cloud_user</code>: elastic</li>
<li><code>cloud_password</code>: You will get it from step 1.6. If you forget to save, Simply click on <em><strong>“Action” -&gt; “Reset password”</strong></em>. (Username will be elastic)</li>
<li><code>openai_api</code>: Create open ai api key from <a href="https://platform.openai.com/account/api-keys">https://platform.openai.com/account/api-keys</a>.</li>
<li><code>es_index</code>: Index name which we created in step 3.3. (search-ashish.one)</li>
<li><code>vector_field</code>: The field which we&rsquo;ve set for destination at step 3.9. i.e. <strong>title-vector</strong></li>
</ol>
<h2 id="setup-on-local-with-docker">Setup on local with Docker</h2>
<ol>
<li>Clone</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>git clone https://github.com/ashishtiwari1993/elasticsearch-chatgpt.git
</span></span><span style="display:flex;"><span>cd elasticsearch-chatgpt
</span></span></code></pre></div><ol start="2">
<li>Replace credentials in <code>Dockerfile</code></li>
</ol>
<p>Open <code>Dockerfile</code> and change below creds</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>ENV openai_api<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;&lt;open_api_key&gt;&#34;</span>
</span></span><span style="display:flex;"><span>ENV cloud_id<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;&lt;elastic cloud id&gt;&#34;</span>
</span></span><span style="display:flex;"><span>ENV cloud_user<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;elastic&#34;</span>
</span></span><span style="display:flex;"><span>ENV cloud_pass<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;&lt;elastic_cloud_password&gt;&#34;</span>
</span></span><span style="display:flex;"><span>ENV es_index<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;&lt;elasticsearch_index_name&gt;&#34;</span>
</span></span><span style="display:flex;"><span>ENV chat_title<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;&lt;Any title for your page e.g. ashish.one GPT&gt;&#34;</span>
</span></span><span style="display:flex;"><span>ENV vector_field<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;&lt; specify vector field where embedding will be save. e.g. title-vector&gt;&#34;</span>
</span></span></code></pre></div><ol start="3">
<li>Build</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>docker build -t es-gpt .
</span></span></code></pre></div><ol start="4">
<li>Run</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>docker run -p 8501:8501 es-gpt
</span></span></code></pre></div><p>Simply visit on <a href="!http://localhost:8501">localhost:8501</a></p>
<h2 id="setup-on-renderhttpsrendercom-with-docker">Setup on <a href="https://render.com/">Render</a> with Docker</h2>
<ol>
<li>
<p>Signup on <a href="https://render.com">https://render.com</a>.</p>
</li>
<li>
<p>Create <strong>Web Service</strong>.</p>
</li>
<li>
<p>Go to <strong>Public Git repository</strong> section and add below repo url</p>
</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>https://github.com/ashishtiwari1993/elasticsearch-chatgpt
</span></span></code></pre></div><p>Hit on <strong>Continue</strong>.</p>
<ol start="4">
<li>
<p>Add <strong>Name</strong> and select <strong>Free</strong> Instance Type.</p>
</li>
<li>
<p>Click on <strong>Advanced</strong> and <strong>Add Environment Variable</strong></p>
</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>openai_api<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;&lt;open_api_key&gt;&#34;</span>
</span></span><span style="display:flex;"><span>cloud_id<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;&lt;elastic cloud id&gt;&#34;</span>
</span></span><span style="display:flex;"><span>cloud_user<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;elastic&#34;</span>
</span></span><span style="display:flex;"><span>cloud_pass<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;&lt;elastic_cloud_password&gt;&#34;</span>
</span></span><span style="display:flex;"><span>es_index<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;&lt;elasticsearch_index_name&gt;&#34;</span>                                                 
</span></span><span style="display:flex;"><span>chat_title<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;&lt;Any title for your page e.g. ashish.one GPT&gt;&#34;</span>
</span></span><span style="display:flex;"><span>vector_field<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;&lt; specify vector field where embedding will be save. e.g. title-vector&gt;&#34;</span>
</span></span></code></pre></div><ol start="6">
<li>Finally click on <strong>Create Web Service</strong></li>
</ol>
<h2 id="output">Output</h2>
<p><img loading="lazy" src="/img/talks/elasticsearch-chatgpt/ashish_one_gpt.gif" alt="ashish.one ChatGPT"  />
</p>
<h1 id="reference">Reference</h1>
<p><a href="https://www.elastic.co/blog/chatgpt-elasticsearch-openai-meets-private-data">Blog - ChatGPT and Elasticsearch: OpenAI meets private data</a></p>
]]></content:encoded>
    </item>
    <item>
      <title>Receive Webhook Requests Using ELK</title>
      <link>https://ashish.one/blogs/elastic/receive-webhook-requests-using-elk/</link>
      <pubDate>Mon, 23 Jan 2023 13:00:09 +0530</pubDate>
      <guid>https://ashish.one/blogs/elastic/receive-webhook-requests-using-elk/</guid>
      <description>&lt;p&gt;In this blog, we will see how you can quickly setup ELK (Elasticsearch, Logstash, Kibana) stack to receive the HTTP webhook. Mostly ELK stack is known for logging purposes. But Elastic stacks are much more beyond the logging use case.
Elastic provides Search, Observability &amp;amp; Security you can check more on this with &lt;a href=&#34;https://www.elastic.co/guide/index.html&#34;&gt;official documentation&lt;/a&gt;.&lt;/p&gt;
&lt;h1 id=&#34;what-is-webhook-&#34;&gt;What is Webhook ?&lt;/h1&gt;
&lt;p&gt;Webhook enables the two programs to communicate or transfer the data with the help of callback functions / hooks. Now in the modern tech world it is also known as Reverse API, Push API etc.
Mostly it is used to send small amounts of data from source to destination. It is a one way data transfer procedure. It works over the HTTP protocol using REST API. It is simple like client and server communication.
Most of the saas allow you to integrate their product with your system with the help of APIs and Webhook only. E.g. Slack and discord allows you to push messages with the help of webhooks. To accept the webhook event, You need to expose one HTTP endpoint lets say&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>In this blog, we will see how you can quickly setup ELK (Elasticsearch, Logstash, Kibana) stack to receive the HTTP webhook. Mostly ELK stack is known for logging purposes. But Elastic stacks are much more beyond the logging use case.
Elastic provides Search, Observability &amp; Security you can check more on this with <a href="https://www.elastic.co/guide/index.html">official documentation</a>.</p>
<h1 id="what-is-webhook-">What is Webhook ?</h1>
<p>Webhook enables the two programs to communicate or transfer the data with the help of callback functions / hooks. Now in the modern tech world it is also known as Reverse API, Push API etc.
Mostly it is used to send small amounts of data from source to destination. It is a one way data transfer procedure. It works over the HTTP protocol using REST API. It is simple like client and server communication.
Most of the saas allow you to integrate their product with your system with the help of APIs and Webhook only. E.g. Slack and discord allows you to push messages with the help of webhooks. To accept the webhook event, You need to expose one HTTP endpoint lets say</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>POST /message
</span></span></code></pre></div><p>In the above example, your system will accept messages from a third party system. Here you can setup authentication, Method, required parameters etc. and convey to users who are going to use this webhook.</p>
<p>So I have to use the <code>POST</code> method, and send data on the above endpoint. You can hit this Endpoint using curl, postman or any programming language.</p>
<h1 id="what-is-elk-">What is ELK ?</h1>
<p>Well from elastic.co -</p>
<p><em>E</em> - <code>Elasticsearch</code> - Elasticsearch is a distributed, free and open search and analytics engine for all types of data, including textual, numerical, geospatial, structured, and unstructured. Check more <a href="https://www.elastic.co/what-is/elasticsearch">here</a>.</p>
<p><em>L</em> - <code>logstash</code> - Logstash is a free and open server-side data processing pipeline that ingests data from a multitude of sources, transforms it, and then sends it to your favorite &ldquo;stash.&rdquo; check more <a href="https://www.elastic.co/logstash/">here</a>.</p>
<p><em>K</em> - <code>Kibana</code> - Kibana is an free and open frontend application that sits on top of the Elastic Stack, providing search and data visualization capabilities for data indexed in Elasticsearch. Check more <a href="https://www.elastic.co/what-is/kibana">here</a>.</p>
<h1 id="the-flow">The Flow</h1>
<p><em><strong>Events -&gt; Logstash -&gt; Elasticsearch &lt;- Kibana</strong></em></p>
<p>Logstash works with three plugins - <a href="https://www.elastic.co/guide/en/logstash/current/input-plugins.html">input</a>, <a href="https://www.elastic.co/guide/en/logstash/current/filter-plugins.html">filter</a>, <a href="https://www.elastic.co/guide/en/logstash/current/output-plugins.html">output</a>.</p>
<p>You can choose any source as a input. For example you can use <a href="https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html">jdbc input plugin</a> to read data from <code>mysql</code>.</p>
<p>Transform your data with the help of <code>filter</code> plugin.</p>
<p>Push the data on destination which you have specified in output plugin.</p>
<p>We will use below plugins to process the webhooks requests.</p>
<ul>
<li>Input plugin -&gt; <a href="https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http.html">HTTP</a></li>
<li>Output plugin -&gt; <a href="https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html">Elasticsearch</a></li>
</ul>
<p>Logstash will process the event and push to the Elasticsearch.
Visualise data from kibana.</p>
<h1 id="implementation">Implementation</h1>
<h2 id="installation">Installation</h2>
<p>You can simply follow the official documentation for installation.</p>
<ul>
<li><strong>Elasticsearch</strong> - <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html</a></li>
<li><strong>Kibana</strong> - <a href="https://www.elastic.co/guide/en/logstash/current/installing-logstash.html">https://www.elastic.co/guide/en/logstash/current/installing-logstash.html</a></li>
<li><strong>Logstash</strong> - <a href="https://www.elastic.co/guide/en/logstash/current/installing-logstash.html">https://www.elastic.co/guide/en/logstash/current/installing-logstash.html</a></li>
</ul>
<p>I am spinning ELK instances using docker. You can choose any method mentioned on above links.</p>
<h2 id="verify">Verify</h2>
<p>Lets verify everything is up and running properly.</p>
<h3 id="elasticsearch">Elasticsearch</h3>
<p>Hit below curl command:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>curl --cacert path/to/ca.crt -u elastic:pass@123 https://localhost:9200
</span></span></code></pre></div><p><strong>Response</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;name&#34;</span> : <span style="color:#e6db74">&#34;es01&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;cluster_name&#34;</span> : <span style="color:#e6db74">&#34;docker-cluster&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;cluster_uuid&#34;</span> : <span style="color:#e6db74">&#34;_CDp3XgbQUKTuQxZWVLh6A&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;version&#34;</span> : {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;number&#34;</span> : <span style="color:#e6db74">&#34;8.6.0&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;build_flavor&#34;</span> : <span style="color:#e6db74">&#34;default&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;build_type&#34;</span> : <span style="color:#e6db74">&#34;docker&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;build_hash&#34;</span> : <span style="color:#e6db74">&#34;f67ef2df40237445caa70e2fef79471cc608d70d&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;build_date&#34;</span> : <span style="color:#e6db74">&#34;2023-01-04T09:35:21.782467981Z&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;build_snapshot&#34;</span> : <span style="color:#66d9ef">false</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;lucene_version&#34;</span> : <span style="color:#e6db74">&#34;9.4.2&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;minimum_wire_compatibility_version&#34;</span> : <span style="color:#e6db74">&#34;7.17.0&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;minimum_index_compatibility_version&#34;</span> : <span style="color:#e6db74">&#34;7.0.0&#34;</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;tagline&#34;</span> : <span style="color:#e6db74">&#34;You Know, for Search&#34;</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><h3 id="logstash">Logstash</h3>
<p>Simply check the log file if there is any error.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>tail -f logs/logstash-plain.log
</span></span></code></pre></div><h3 id="kibana">Kibana</h3>
<p>Simply visit <code>https://localhost:5601</code>. Try to login in kibana with credentials.</p>
<p>Now the ELK stack is up and running. Lets create the logstash configuration file to receive the webhook request and push to elasticsearch.</p>
<h2 id="logstash-pipeline">Logstash pipeline</h2>
<p>Create file <code>webhook.conf</code> on the path which you have specified at <code>path.config</code> settings. You can set this setting at <code>config/logstash.yml</code> or <code>config/pipeline.yml</code>.</p>
<h3 id="webhookconf"><code>webhook.conf</code></h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>input <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  http <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    port <span style="color:#f92672">=</span>&gt; <span style="color:#ae81ff">4000</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>filter <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  json <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    source <span style="color:#f92672">=</span>&gt; <span style="color:#e6db74">&#34;message&#34;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>output <span style="color:#f92672">{</span>   
</span></span><span style="display:flex;"><span>  elasticsearch <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    hosts <span style="color:#f92672">=</span>&gt; <span style="color:#f92672">[</span><span style="color:#e6db74">&#34;https://es01:9200&#34;</span><span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>    cacert <span style="color:#f92672">=</span>&gt; <span style="color:#e6db74">&#39;/usr/share/logstash/pipeline/certs/ca.crt&#39;</span>
</span></span><span style="display:flex;"><span>    user <span style="color:#f92672">=</span>&gt; <span style="color:#e6db74">&#39;elastic&#39;</span>
</span></span><span style="display:flex;"><span>    password <span style="color:#f92672">=</span>&gt; <span style="color:#e6db74">&#39;pass@123&#39;</span>
</span></span><span style="display:flex;"><span>    index <span style="color:#f92672">=</span>&gt; <span style="color:#e6db74">&#39;webhook&#39;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We are configuring HTTP endpoint on port <code>4000</code>. So whenever anyone calls the webhook endpoint, they need to specify port like <code>http://mydomain.com:4000</code></p>
<p>Here i am only defining the index but you can configure data stream as well. Check <a href="https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html">here</a> for more options.</p>
<h3 id="test-configuration">Test configuration</h3>
<p>Run pipeline with below command:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>./bin/logstash -f webhook-receiver.conf
</span></span></code></pre></div><p>Check if any errors are there.</p>
<p>If everything seems fine, Let&rsquo;s start the logstash service.</p>
<h2 id="test">Test</h2>
<p>Push sample data</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>curl -XPOST -H <span style="color:#e6db74">&#39;Content-type:applicaton/json&#39;</span> http://localhost:4000 -d <span style="color:#e6db74">&#39;{&#34;test_key1&#34;:&#34;test_value1&#34;,&#34;info&#34;:{&#34;name&#34;:&#34;Ashish&#34;,&#34;last_name&#34;:&#34;Tiwari&#34;},&#34;my_list&#34;:[&#34;el1&#34;,&#34;el2&#34;]}&#39;</span>
</span></span></code></pre></div><p><strong>Response</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>ok%
</span></span></code></pre></div><p>Verify data in elasticsearch</p>
<p>Login to kibana by visiting <code>localhost:5601</code>.</p>
<p>Navigate to <strong><strong>Menu -&gt; Management -&gt; Dev Tools</strong></strong></p>
<p>Lets see if Index is created or not.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>GET _cat/indices?v
</span></span></code></pre></div><p><strong>Response</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>health status index   uuid                   pri rep docs.count docs.deleted store.size pri.store.size
</span></span><span style="display:flex;"><span>yellow open   webhook LiXxWLy5QvKkpYpmLLbYsw   <span style="color:#ae81ff">1</span>   <span style="color:#ae81ff">1</span>          <span style="color:#ae81ff">1</span>            <span style="color:#ae81ff">0</span>     12.5kb         12.5kb
</span></span></code></pre></div><p>I can see the index <code>webhook</code> has been created. Also the <code>docs.count</code> is 1 which means data has been inserted.</p>
<p>Lets see the data.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>GET webhook/_search
</span></span></code></pre></div><p><strong>Response</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;took&#34;</span>: <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;timed_out&#34;</span>: <span style="color:#66d9ef">false</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;_shards&#34;</span>: {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;total&#34;</span>: <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;successful&#34;</span>: <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;skipped&#34;</span>: <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;failed&#34;</span>: <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;hits&#34;</span>: {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;total&#34;</span>: {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;value&#34;</span>: <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;relation&#34;</span>: <span style="color:#e6db74">&#34;eq&#34;</span>
</span></span><span style="display:flex;"><span>    },
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;max_score&#34;</span>: <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;hits&#34;</span>: [
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_index&#34;</span>: <span style="color:#e6db74">&#34;webhook&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_id&#34;</span>: <span style="color:#e6db74">&#34;-ok63YUBrNdmvLyIE5Ue&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_score&#34;</span>: <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_source&#34;</span>: {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;host&#34;</span>: {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;ip&#34;</span>: <span style="color:#e6db74">&#34;192.168.192.1&#34;</span>
</span></span><span style="display:flex;"><span>          },
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;my_list&#34;</span>: [
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;el1&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;el2&#34;</span>
</span></span><span style="display:flex;"><span>          ],
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;message&#34;</span>: <span style="color:#e6db74">&#34;&#34;&#34;{&#34;</span><span style="color:#960050;background-color:#1e0010">test_key</span><span style="color:#ae81ff">1</span><span style="color:#e6db74">&#34;:&#34;</span><span style="color:#960050;background-color:#1e0010">test_value</span><span style="color:#ae81ff">1</span><span style="color:#e6db74">&#34;,&#34;</span><span style="color:#960050;background-color:#1e0010">info</span><span style="color:#e6db74">&#34;:{&#34;</span><span style="color:#960050;background-color:#1e0010">name</span><span style="color:#e6db74">&#34;:&#34;</span><span style="color:#960050;background-color:#1e0010">Ashish</span><span style="color:#e6db74">&#34;,&#34;</span><span style="color:#960050;background-color:#1e0010">last_name</span><span style="color:#e6db74">&#34;:&#34;</span><span style="color:#960050;background-color:#1e0010">Tiwari</span><span style="color:#e6db74">&#34;},&#34;</span><span style="color:#960050;background-color:#1e0010">my_list</span><span style="color:#e6db74">&#34;:[&#34;</span><span style="color:#960050;background-color:#1e0010">el</span><span style="color:#ae81ff">1</span><span style="color:#e6db74">&#34;,&#34;</span><span style="color:#960050;background-color:#1e0010">el</span><span style="color:#ae81ff">2</span><span style="color:#e6db74">&#34;]}&#34;&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;event&#34;</span>: {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;original&#34;</span>: <span style="color:#e6db74">&#34;&#34;&#34;{&#34;</span><span style="color:#960050;background-color:#1e0010">test_key</span><span style="color:#ae81ff">1</span><span style="color:#e6db74">&#34;:&#34;</span><span style="color:#960050;background-color:#1e0010">test_value</span><span style="color:#ae81ff">1</span><span style="color:#e6db74">&#34;,&#34;</span><span style="color:#960050;background-color:#1e0010">info</span><span style="color:#e6db74">&#34;:{&#34;</span><span style="color:#960050;background-color:#1e0010">name</span><span style="color:#e6db74">&#34;:&#34;</span><span style="color:#960050;background-color:#1e0010">Ashish</span><span style="color:#e6db74">&#34;,&#34;</span><span style="color:#960050;background-color:#1e0010">last_name</span><span style="color:#e6db74">&#34;:&#34;</span><span style="color:#960050;background-color:#1e0010">Tiwari</span><span style="color:#e6db74">&#34;},&#34;</span><span style="color:#960050;background-color:#1e0010">my_list</span><span style="color:#e6db74">&#34;:[&#34;</span><span style="color:#960050;background-color:#1e0010">el</span><span style="color:#ae81ff">1</span><span style="color:#e6db74">&#34;,&#34;</span><span style="color:#960050;background-color:#1e0010">el</span><span style="color:#ae81ff">2</span><span style="color:#e6db74">&#34;]}&#34;&#34;&#34;</span>
</span></span><span style="display:flex;"><span>          },
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;@version&#34;</span>: <span style="color:#e6db74">&#34;1&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;@timestamp&#34;</span>: <span style="color:#e6db74">&#34;2023-01-23T06:04:08.664398594Z&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;http&#34;</span>: {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;version&#34;</span>: <span style="color:#e6db74">&#34;HTTP/1.1&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;method&#34;</span>: <span style="color:#e6db74">&#34;POST&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;request&#34;</span>: {
</span></span><span style="display:flex;"><span>              <span style="color:#f92672">&#34;mime_type&#34;</span>: <span style="color:#e6db74">&#34;applicaton/json&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#f92672">&#34;body&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;bytes&#34;</span>: <span style="color:#e6db74">&#34;97&#34;</span>
</span></span><span style="display:flex;"><span>              }
</span></span><span style="display:flex;"><span>            }
</span></span><span style="display:flex;"><span>          },
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;info&#34;</span>: {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;last_name&#34;</span>: <span style="color:#e6db74">&#34;Tiwari&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;Ashish&#34;</span>
</span></span><span style="display:flex;"><span>          },
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;user_agent&#34;</span>: {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;original&#34;</span>: <span style="color:#e6db74">&#34;curl/7.79.1&#34;</span>
</span></span><span style="display:flex;"><span>          },
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;url&#34;</span>: {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;domain&#34;</span>: <span style="color:#e6db74">&#34;localhost&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;port&#34;</span>: <span style="color:#ae81ff">4000</span>
</span></span><span style="display:flex;"><span>          },
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;test_key1&#34;</span>: <span style="color:#e6db74">&#34;test_value1&#34;</span>
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>    ]
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><img loading="lazy" src="/img/elastic/index-search.png" alt="index-search"  />
</p>
<p>If you are able to see data like above, Your webhook receiver is all set to accept requests.</p>
<h2 id="data-visualisation">Data Visualisation</h2>
<p>Simply navigate to <em><strong>Menu -&gt; Analytics -&gt; Discover</strong></em></p>
<p>Create a <code>Data View</code> on the index <code>webhook</code>.</p>
<p><img loading="lazy" src="/img/elastic/data-view.png" alt="Data View"  />
</p>
<p>To create the dashboard, go to <em><strong>Menu -&gt; Analytics -&gt; Dashboard</strong></em>. You can create a dashboard according to your requirement.</p>
<h1 id="conclusion">Conclusion</h1>
<p>We have successfully set up the webhook receiver with the help of ELK stack. Though ELK use cases are very vast. There are various <a href="https://www.elastic.co/guide/en/logstash/current/input-plugins.html">input</a> and <a href="https://www.elastic.co/guide/en/logstash/current/output-plugins.html">output</a> plugins available in logstash for data pipelines.</p>
]]></content:encoded>
    </item>
    <item>
      <title>Kubernetes generic errors</title>
      <link>https://ashish.one/blogs/k8s/k8s-generic-errors/</link>
      <pubDate>Sat, 07 Jan 2023 22:41:02 +0530</pubDate>
      <guid>https://ashish.one/blogs/k8s/k8s-generic-errors/</guid>
      <description>&lt;h2 id=&#34;1-unknown-service-runtimev1alpha2imageservice&#34;&gt;1. unknown service runtime.v1alpha2.ImageService&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Error: pulling image: rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.ImageService&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id=&#34;system-configuration&#34;&gt;System configuration&lt;/h3&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;centos 9 / 2GB RAM / 2CPU
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;master-node&#34;&gt;Master Node&lt;/h3&gt;
&lt;p&gt;Same issue on master node.&lt;/p&gt;
&lt;h4 id=&#34;command&#34;&gt;Command&lt;/h4&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;root@kube-master-1 ~&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# kubeadm config images pull&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;failed to pull image &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;registry.k8s.io/kube-apiserver:v1.26.0&amp;#34;&lt;/span&gt;: output: E0107 14:52:09.997544    &lt;span style=&#34;color:#ae81ff&#34;&gt;4134&lt;/span&gt; remote_image.go:222&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;PullImage from image service failed&amp;#34;&lt;/span&gt; err&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.ImageService&amp;#34;&lt;/span&gt; image&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;registry.k8s.io/kube-apiserver:v1.26.0&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;time&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2023-01-07T14:52:09Z&amp;#34;&lt;/span&gt; level&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;fatal msg&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;pulling image: rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.ImageService&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;, error: exit status &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;To see the stack trace of this error execute with --v&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;5&lt;/span&gt; or higher
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;-solved&#34;&gt;✅ Solved&lt;/h4&gt;
&lt;p&gt;Remove below file:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h2 id="1-unknown-service-runtimev1alpha2imageservice">1. unknown service runtime.v1alpha2.ImageService</h2>
<blockquote>
<p>Error: pulling image: rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.ImageService</p>
</blockquote>
<h3 id="system-configuration">System configuration</h3>
<pre tabindex="0"><code>centos 9 / 2GB RAM / 2CPU
</code></pre><h3 id="master-node">Master Node</h3>
<p>Same issue on master node.</p>
<h4 id="command">Command</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="color:#f92672">[</span>root@kube-master-1 ~<span style="color:#f92672">]</span><span style="color:#75715e"># kubeadm config images pull</span>
</span></span><span style="display:flex;"><span>failed to pull image <span style="color:#e6db74">&#34;registry.k8s.io/kube-apiserver:v1.26.0&#34;</span>: output: E0107 14:52:09.997544    <span style="color:#ae81ff">4134</span> remote_image.go:222<span style="color:#f92672">]</span> <span style="color:#e6db74">&#34;PullImage from image service failed&#34;</span> err<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.ImageService&#34;</span> image<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;registry.k8s.io/kube-apiserver:v1.26.0&#34;</span>
</span></span><span style="display:flex;"><span>time<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;2023-01-07T14:52:09Z&#34;</span> level<span style="color:#f92672">=</span>fatal msg<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;pulling image: rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.ImageService&#34;</span>
</span></span><span style="display:flex;"><span>, error: exit status <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>To see the stack trace of this error execute with --v<span style="color:#f92672">=</span><span style="color:#ae81ff">5</span> or higher
</span></span></code></pre></div><h4 id="-solved">✅ Solved</h4>
<p>Remove below file:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>rm /etc/containerd/config.toml
</span></span></code></pre></div><p>Try again.</p>
<h3 id="worker-node">Worker Node</h3>
<p>Same issue on worker node while joining to master.</p>
<h4 id="command-1">Command</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="color:#f92672">[</span>root@kube-worker-2 ~<span style="color:#f92672">]</span><span style="color:#75715e"># kubeadm join x.x.x.x:6443 --token ga8bqg.01azxe9avjx2n6jr        --discovery-token-ca-cert-hash sha256:d57699d74721094e5f921d48a0f9f895a0d7def7e1977e95ce0027a03e7f7d39</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>preflight<span style="color:#f92672">]</span> Running pre-flight checks
</span></span><span style="display:flex;"><span>error execution phase preflight: <span style="color:#f92672">[</span>preflight<span style="color:#f92672">]</span> Some fatal errors occurred:
</span></span><span style="display:flex;"><span>	<span style="color:#f92672">[</span>ERROR CRI<span style="color:#f92672">]</span>: container runtime is not running: output: E0107 17:46:12.269694   <span style="color:#ae81ff">11160</span> remote_runtime.go:948<span style="color:#f92672">]</span> <span style="color:#e6db74">&#34;Status from runtime service failed&#34;</span> err<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.RuntimeService&#34;</span>
</span></span><span style="display:flex;"><span>time<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;2023-01-07T17:46:12Z&#34;</span> level<span style="color:#f92672">=</span>fatal msg<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;getting status of runtime: rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.RuntimeService&#34;</span>
</span></span><span style="display:flex;"><span>, error: exit status <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>preflight<span style="color:#f92672">]</span> If you know what you are doing, you can make a check non-fatal with <span style="color:#e6db74">`</span>--ignore-preflight-errors<span style="color:#f92672">=</span>...<span style="color:#e6db74">`</span>
</span></span><span style="display:flex;"><span>To see the stack trace of this error execute with --v<span style="color:#f92672">=</span><span style="color:#ae81ff">5</span> or higher
</span></span></code></pre></div><h4 id="-solved-1">✅ Solved</h4>
<p>Same remove the <code>config.toml</code> file and restart the <code>containerd</code> service.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>rm /etc/containerd/config.toml
</span></span><span style="display:flex;"><span>systemctl restart containerd
</span></span></code></pre></div>]]></content:encoded>
    </item>
    <item>
      <title>Getting started with Elastic stack</title>
      <link>https://ashish.one/talks/getting_started_elastic_stack/</link>
      <pubDate>Sat, 17 Sep 2022 19:24:45 +0000</pubDate>
      <guid>https://ashish.one/talks/getting_started_elastic_stack/</guid>
      <description>&lt;h2 id=&#34;what-this-talk-is-all-about-&#34;&gt;What this talk is all about ?&lt;/h2&gt;
&lt;p&gt;Elastic Stack (Elasticsearch, Logstash, Kibana and Beats) is such a platform which is built for scalability, performance and “You know&amp;hellip; for Search”. When you have a system which scales to the horizons of your data, helps you in your data quest, shows you insights - imagine what you can do with it.&lt;/p&gt;
&lt;h2 id=&#34;talk-video&#34;&gt;Talk Video&lt;/h2&gt;


    
    &lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;
      &lt;iframe allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&#34; allowfullscreen=&#34;allowfullscreen&#34; loading=&#34;eager&#34; referrerpolicy=&#34;strict-origin-when-cross-origin&#34; src=&#34;https://www.youtube.com/embed/hJoorF6zxBA?autoplay=0&amp;controls=1&amp;end=0&amp;loop=0&amp;mute=0&amp;start=0&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;YouTube video&#34;
      &gt;&lt;/iframe&gt;
    &lt;/div&gt;

&lt;h4 id=&#34;feel-free-to-comment-below-if-you-have-any-doubts-or-suggestion-about-this-talk&#34;&gt;Feel free to comment below, If you have any doubts or suggestion about this talk.&lt;/h4&gt;</description>
      <content:encoded><![CDATA[<h2 id="what-this-talk-is-all-about-">What this talk is all about ?</h2>
<p>Elastic Stack (Elasticsearch, Logstash, Kibana and Beats) is such a platform which is built for scalability, performance and “You know&hellip; for Search”. When you have a system which scales to the horizons of your data, helps you in your data quest, shows you insights - imagine what you can do with it.</p>
<h2 id="talk-video">Talk Video</h2>


    
    <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/hJoorF6zxBA?autoplay=0&controls=1&end=0&loop=0&mute=0&start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"
      ></iframe>
    </div>

<h4 id="feel-free-to-comment-below-if-you-have-any-doubts-or-suggestion-about-this-talk">Feel free to comment below, If you have any doubts or suggestion about this talk.</h4>
]]></content:encoded>
    </item>
    <item>
      <title>Getting started with Elasticsearch</title>
      <link>https://ashish.one/talks/ws-es/</link>
      <pubDate>Wed, 14 Sep 2022 17:44:43 +0530</pubDate>
      <guid>https://ashish.one/talks/ws-es/</guid>
      <description>&lt;h1 id=&#34;sample-queries-for-elasticsearch-workshop&#34;&gt;Sample Queries for Elasticsearch Workshop&lt;/h1&gt;
&lt;h2 id=&#34;crud&#34;&gt;CRUD&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
# Insert

POST meetup/_doc/
{
  &amp;#34;name&amp;#34;:&amp;#34;Ashish Tiwari&amp;#34;
}

# Insert with id

POST meetup/_doc/1
{
  &amp;#34;name&amp;#34;:&amp;#34;Ashish Tiwari&amp;#34;
}

# Search

GET meetup/_search

# Update

POST meetup/_doc/1
{
  &amp;#34;name&amp;#34;:&amp;#34;Ashish&amp;#34;,
  &amp;#34;company&amp;#34;:&amp;#34;elastic&amp;#34;,
  &amp;#34;address&amp;#34;:&amp;#34;Navi Mumbai kharghar&amp;#34;,
  &amp;#34;skills&amp;#34;:{
    &amp;#34;language&amp;#34;:[&amp;#34;php&amp;#34;,&amp;#34;java&amp;#34;,&amp;#34;node&amp;#34;],
    &amp;#34;database&amp;#34;:[&amp;#34;mysql&amp;#34;,&amp;#34;mongodb&amp;#34;],
    &amp;#34;search&amp;#34;:&amp;#34;elasticsearch&amp;#34;
  }
}

# search with query

GET meetup/_search
{
  &amp;#34;query&amp;#34;: {
    &amp;#34;match&amp;#34;: {
      &amp;#34;address&amp;#34;: &amp;#34;navi&amp;#34;
    }
  }
}

# delete

DELETE meetup
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;bulk&#34;&gt;BULK&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;POST _bulk
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:1,&amp;#34;first_name&amp;#34;:&amp;#34;Yvonne&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Willmott&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;ywillmott0@live.com&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Female&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;38 Helena Avenue&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;104.221.25.110&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Flashset&amp;#34;}
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:2,&amp;#34;first_name&amp;#34;:&amp;#34;Immanuel&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Philbrick&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;iphilbrick1@wunderground.com&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Male&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;01 Bunting Pass&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;9.20.164.27&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Babblestorm&amp;#34;}
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:3,&amp;#34;first_name&amp;#34;:&amp;#34;Clotilda&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Danelut&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;cdanelut2@deliciousdays.com&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Agender&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;0 Crowley Trail&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;158.94.144.140&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Riffpedia&amp;#34;}
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:4,&amp;#34;first_name&amp;#34;:&amp;#34;Nahum&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Attfield&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;nattfield3@blog.com&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Male&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;7 Garrison Court&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;225.144.148.44&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Chatterpoint&amp;#34;}
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:5,&amp;#34;first_name&amp;#34;:&amp;#34;Vaughan&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Middis&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;vmiddis4@ted.com&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Male&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;7 Cody Way&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;66.198.31.108&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Mynte&amp;#34;}
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:6,&amp;#34;first_name&amp;#34;:&amp;#34;Nolie&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Alessandrucci&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;nalessandrucci5@networksolutions.com&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Male&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;826 Brown Hill&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;96.77.221.95&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Feedfish&amp;#34;}
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:7,&amp;#34;first_name&amp;#34;:&amp;#34;Beverlie&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Ovitts&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;bovitts6@tripod.com&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Male&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;6 Sycamore Pass&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;102.24.117.107&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Zazio&amp;#34;}
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:8,&amp;#34;first_name&amp;#34;:&amp;#34;Graeme&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Dopson&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;gdopson7@free.fr&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Female&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;26 Dunning Avenue&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;198.33.215.93&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Flashset&amp;#34;}
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:9,&amp;#34;first_name&amp;#34;:&amp;#34;Mellisa&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Hurich&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;mhurich8@nbcnews.com&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Male&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;6371 Browning Way&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;66.0.3.199&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Divanoodle&amp;#34;}
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:10,&amp;#34;first_name&amp;#34;:&amp;#34;Dyan&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Loude&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;dloude9@berkeley.edu&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Female&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;9818 Reindahl Road&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;16.56.137.54&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Agivu&amp;#34;}
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:11,&amp;#34;first_name&amp;#34;:&amp;#34;Becky&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Shank&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;bshanka@tinypic.com&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Male&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;1206 Warrior Terrace&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;90.63.35.111&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Izio&amp;#34;}
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:12,&amp;#34;first_name&amp;#34;:&amp;#34;Bar&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Bedburrow&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;bbedburrowb@vistaprint.com&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Male&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;75 Onsgard Crossing&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;85.122.33.250&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Zoombox&amp;#34;}
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:13,&amp;#34;first_name&amp;#34;:&amp;#34;Dorey&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Isenor&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;disenorc@privacy.gov.au&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Female&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;53682 Parkside Crossing&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;150.158.150.213&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Rhyzio&amp;#34;}
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:14,&amp;#34;first_name&amp;#34;:&amp;#34;Torrin&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Rangall&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;trangalld@buzzfeed.com&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Male&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;24247 Old Shore Plaza&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;40.151.17.2&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Devpoint&amp;#34;}
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:15,&amp;#34;first_name&amp;#34;:&amp;#34;Genvieve&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Beslier&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;gbesliere@yolasite.com&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Male&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;96214 Miller Trail&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;115.143.68.208&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Oyonder&amp;#34;}
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:16,&amp;#34;first_name&amp;#34;:&amp;#34;Arden&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Ramas&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;aramasf@whitehouse.gov&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Polygender&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;390 Gulseth Alley&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;36.83.126.154&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Youbridge&amp;#34;}
{&amp;#34;index&amp;#34;:{&amp;#34;_index&amp;#34;:&amp;#34;meetup&amp;#34;}}
{&amp;#34;user_id&amp;#34;:17,&amp;#34;first_name&amp;#34;:&amp;#34;Alyosha&amp;#34;,&amp;#34;last_name&amp;#34;:&amp;#34;Domm&amp;#34;,&amp;#34;email&amp;#34;:&amp;#34;adommg@washingtonpost.com&amp;#34;,&amp;#34;gender&amp;#34;:&amp;#34;Female&amp;#34;,&amp;#34;street_address&amp;#34;:&amp;#34;32 Oxford Way&amp;#34;,&amp;#34;ip_address&amp;#34;:&amp;#34;174.71.176.45&amp;#34;,&amp;#34;company&amp;#34;:&amp;#34;Wikizz&amp;#34;}
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;upload-sample-json-data-from-kibana&#34;&gt;Upload sample json data from kibana&lt;/h2&gt;
&lt;p&gt;Download &lt;a href=&#34;https://ashish.one/data/movies.json&#34;&gt;movies.json&lt;/a&gt; and insert into elasticsearch by using below command:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h1 id="sample-queries-for-elasticsearch-workshop">Sample Queries for Elasticsearch Workshop</h1>
<h2 id="crud">CRUD</h2>
<pre tabindex="0"><code>
# Insert

POST meetup/_doc/
{
  &#34;name&#34;:&#34;Ashish Tiwari&#34;
}

# Insert with id

POST meetup/_doc/1
{
  &#34;name&#34;:&#34;Ashish Tiwari&#34;
}

# Search

GET meetup/_search

# Update

POST meetup/_doc/1
{
  &#34;name&#34;:&#34;Ashish&#34;,
  &#34;company&#34;:&#34;elastic&#34;,
  &#34;address&#34;:&#34;Navi Mumbai kharghar&#34;,
  &#34;skills&#34;:{
    &#34;language&#34;:[&#34;php&#34;,&#34;java&#34;,&#34;node&#34;],
    &#34;database&#34;:[&#34;mysql&#34;,&#34;mongodb&#34;],
    &#34;search&#34;:&#34;elasticsearch&#34;
  }
}

# search with query

GET meetup/_search
{
  &#34;query&#34;: {
    &#34;match&#34;: {
      &#34;address&#34;: &#34;navi&#34;
    }
  }
}

# delete

DELETE meetup
</code></pre><h2 id="bulk">BULK</h2>
<pre tabindex="0"><code>POST _bulk
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:1,&#34;first_name&#34;:&#34;Yvonne&#34;,&#34;last_name&#34;:&#34;Willmott&#34;,&#34;email&#34;:&#34;ywillmott0@live.com&#34;,&#34;gender&#34;:&#34;Female&#34;,&#34;street_address&#34;:&#34;38 Helena Avenue&#34;,&#34;ip_address&#34;:&#34;104.221.25.110&#34;,&#34;company&#34;:&#34;Flashset&#34;}
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:2,&#34;first_name&#34;:&#34;Immanuel&#34;,&#34;last_name&#34;:&#34;Philbrick&#34;,&#34;email&#34;:&#34;iphilbrick1@wunderground.com&#34;,&#34;gender&#34;:&#34;Male&#34;,&#34;street_address&#34;:&#34;01 Bunting Pass&#34;,&#34;ip_address&#34;:&#34;9.20.164.27&#34;,&#34;company&#34;:&#34;Babblestorm&#34;}
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:3,&#34;first_name&#34;:&#34;Clotilda&#34;,&#34;last_name&#34;:&#34;Danelut&#34;,&#34;email&#34;:&#34;cdanelut2@deliciousdays.com&#34;,&#34;gender&#34;:&#34;Agender&#34;,&#34;street_address&#34;:&#34;0 Crowley Trail&#34;,&#34;ip_address&#34;:&#34;158.94.144.140&#34;,&#34;company&#34;:&#34;Riffpedia&#34;}
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:4,&#34;first_name&#34;:&#34;Nahum&#34;,&#34;last_name&#34;:&#34;Attfield&#34;,&#34;email&#34;:&#34;nattfield3@blog.com&#34;,&#34;gender&#34;:&#34;Male&#34;,&#34;street_address&#34;:&#34;7 Garrison Court&#34;,&#34;ip_address&#34;:&#34;225.144.148.44&#34;,&#34;company&#34;:&#34;Chatterpoint&#34;}
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:5,&#34;first_name&#34;:&#34;Vaughan&#34;,&#34;last_name&#34;:&#34;Middis&#34;,&#34;email&#34;:&#34;vmiddis4@ted.com&#34;,&#34;gender&#34;:&#34;Male&#34;,&#34;street_address&#34;:&#34;7 Cody Way&#34;,&#34;ip_address&#34;:&#34;66.198.31.108&#34;,&#34;company&#34;:&#34;Mynte&#34;}
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:6,&#34;first_name&#34;:&#34;Nolie&#34;,&#34;last_name&#34;:&#34;Alessandrucci&#34;,&#34;email&#34;:&#34;nalessandrucci5@networksolutions.com&#34;,&#34;gender&#34;:&#34;Male&#34;,&#34;street_address&#34;:&#34;826 Brown Hill&#34;,&#34;ip_address&#34;:&#34;96.77.221.95&#34;,&#34;company&#34;:&#34;Feedfish&#34;}
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:7,&#34;first_name&#34;:&#34;Beverlie&#34;,&#34;last_name&#34;:&#34;Ovitts&#34;,&#34;email&#34;:&#34;bovitts6@tripod.com&#34;,&#34;gender&#34;:&#34;Male&#34;,&#34;street_address&#34;:&#34;6 Sycamore Pass&#34;,&#34;ip_address&#34;:&#34;102.24.117.107&#34;,&#34;company&#34;:&#34;Zazio&#34;}
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:8,&#34;first_name&#34;:&#34;Graeme&#34;,&#34;last_name&#34;:&#34;Dopson&#34;,&#34;email&#34;:&#34;gdopson7@free.fr&#34;,&#34;gender&#34;:&#34;Female&#34;,&#34;street_address&#34;:&#34;26 Dunning Avenue&#34;,&#34;ip_address&#34;:&#34;198.33.215.93&#34;,&#34;company&#34;:&#34;Flashset&#34;}
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:9,&#34;first_name&#34;:&#34;Mellisa&#34;,&#34;last_name&#34;:&#34;Hurich&#34;,&#34;email&#34;:&#34;mhurich8@nbcnews.com&#34;,&#34;gender&#34;:&#34;Male&#34;,&#34;street_address&#34;:&#34;6371 Browning Way&#34;,&#34;ip_address&#34;:&#34;66.0.3.199&#34;,&#34;company&#34;:&#34;Divanoodle&#34;}
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:10,&#34;first_name&#34;:&#34;Dyan&#34;,&#34;last_name&#34;:&#34;Loude&#34;,&#34;email&#34;:&#34;dloude9@berkeley.edu&#34;,&#34;gender&#34;:&#34;Female&#34;,&#34;street_address&#34;:&#34;9818 Reindahl Road&#34;,&#34;ip_address&#34;:&#34;16.56.137.54&#34;,&#34;company&#34;:&#34;Agivu&#34;}
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:11,&#34;first_name&#34;:&#34;Becky&#34;,&#34;last_name&#34;:&#34;Shank&#34;,&#34;email&#34;:&#34;bshanka@tinypic.com&#34;,&#34;gender&#34;:&#34;Male&#34;,&#34;street_address&#34;:&#34;1206 Warrior Terrace&#34;,&#34;ip_address&#34;:&#34;90.63.35.111&#34;,&#34;company&#34;:&#34;Izio&#34;}
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:12,&#34;first_name&#34;:&#34;Bar&#34;,&#34;last_name&#34;:&#34;Bedburrow&#34;,&#34;email&#34;:&#34;bbedburrowb@vistaprint.com&#34;,&#34;gender&#34;:&#34;Male&#34;,&#34;street_address&#34;:&#34;75 Onsgard Crossing&#34;,&#34;ip_address&#34;:&#34;85.122.33.250&#34;,&#34;company&#34;:&#34;Zoombox&#34;}
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:13,&#34;first_name&#34;:&#34;Dorey&#34;,&#34;last_name&#34;:&#34;Isenor&#34;,&#34;email&#34;:&#34;disenorc@privacy.gov.au&#34;,&#34;gender&#34;:&#34;Female&#34;,&#34;street_address&#34;:&#34;53682 Parkside Crossing&#34;,&#34;ip_address&#34;:&#34;150.158.150.213&#34;,&#34;company&#34;:&#34;Rhyzio&#34;}
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:14,&#34;first_name&#34;:&#34;Torrin&#34;,&#34;last_name&#34;:&#34;Rangall&#34;,&#34;email&#34;:&#34;trangalld@buzzfeed.com&#34;,&#34;gender&#34;:&#34;Male&#34;,&#34;street_address&#34;:&#34;24247 Old Shore Plaza&#34;,&#34;ip_address&#34;:&#34;40.151.17.2&#34;,&#34;company&#34;:&#34;Devpoint&#34;}
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:15,&#34;first_name&#34;:&#34;Genvieve&#34;,&#34;last_name&#34;:&#34;Beslier&#34;,&#34;email&#34;:&#34;gbesliere@yolasite.com&#34;,&#34;gender&#34;:&#34;Male&#34;,&#34;street_address&#34;:&#34;96214 Miller Trail&#34;,&#34;ip_address&#34;:&#34;115.143.68.208&#34;,&#34;company&#34;:&#34;Oyonder&#34;}
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:16,&#34;first_name&#34;:&#34;Arden&#34;,&#34;last_name&#34;:&#34;Ramas&#34;,&#34;email&#34;:&#34;aramasf@whitehouse.gov&#34;,&#34;gender&#34;:&#34;Polygender&#34;,&#34;street_address&#34;:&#34;390 Gulseth Alley&#34;,&#34;ip_address&#34;:&#34;36.83.126.154&#34;,&#34;company&#34;:&#34;Youbridge&#34;}
{&#34;index&#34;:{&#34;_index&#34;:&#34;meetup&#34;}}
{&#34;user_id&#34;:17,&#34;first_name&#34;:&#34;Alyosha&#34;,&#34;last_name&#34;:&#34;Domm&#34;,&#34;email&#34;:&#34;adommg@washingtonpost.com&#34;,&#34;gender&#34;:&#34;Female&#34;,&#34;street_address&#34;:&#34;32 Oxford Way&#34;,&#34;ip_address&#34;:&#34;174.71.176.45&#34;,&#34;company&#34;:&#34;Wikizz&#34;}
</code></pre><h2 id="upload-sample-json-data-from-kibana">Upload sample json data from kibana</h2>
<p>Download <a href="/data/movies.json">movies.json</a> and insert into elasticsearch by using below command:</p>
<p><em>Open Kibana -&gt; Menu -&gt; Home -&gt; Upload a file</em></p>
<h2 id="create-data-view-in-kibana">Create Data view in Kibana</h2>
<p><em>Open Kibana -&gt; Menu -&gt; Stack Management -&gt; Data Views (Kibana)</em></p>
<h2 id="create-dashboard">Create Dashboard</h2>
<p><em>Open Kibana -&gt; Menu -&gt; Analytics -&gt; Dashboard</em></p>
<h2 id="create-mapping">Create mapping</h2>
<pre tabindex="0"><code>PUT /devfest-raipur
{
  &#34;mappings&#34;: {
    &#34;properties&#34;: {
      &#34;age&#34;:    { &#34;type&#34;: &#34;integer&#34; },  
      &#34;email&#34;:  { &#34;type&#34;: &#34;keyword&#34;  }, 
      &#34;name&#34;:   { &#34;type&#34;: &#34;text&#34;  }     
    }
  }
}
</code></pre><h2 id="analyze">Analyze</h2>
<pre tabindex="0"><code># analyze

GET /_analyze?pretty
{
  &#34;text&#34; : &#34;Quick Brown Foxes!&#34;
}

# Whitespace

GET _analyze
{
  &#34;analyzer&#34;: &#34;whitespace&#34;,
  &#34;text&#34;: &#34;The 2 QUICK Brown-Foxes jumped over the lazy dog\u0027s bone.&#34;
}
</code></pre><h3 id="what-is-an-analyzer">What is an analyzer?</h3>
<p>An analyzer is made of character filters, tokenizer and token filters.</p>
<p>Let&rsquo;s build one</p>
<pre tabindex="0"><code>POST _analyze
{
  &#34;char_filter&#34;: [], 
  &#34;tokenizer&#34;:   &#34;standard&#34;,
  &#34;filter&#34;:      [], 
  &#34;text&#34;: [ 
    &#34;I like when the &lt;strong&gt;quick&lt;/strong&gt; foxes jumps over lazy DOGS!&#34;,
    &#34;and &lt;strong&gt;fast&lt;/strong&gt;&#34;
  ]
}
</code></pre><p>Let&rsquo;s remove the html code.</p>
<pre tabindex="0"><code>POST _analyze
{
  &#34;char_filter&#34;: [&#34;html_strip&#34;], 
  &#34;tokenizer&#34;:   &#34;standard&#34;,
  &#34;filter&#34;:      [], 
  &#34;text&#34;: [ 
    &#34;I like when the &lt;strong&gt;quick&lt;/strong&gt; foxes jumps over lazy DOGS!&#34;,
    &#34;and &lt;strong&gt;fast&lt;/strong&gt;&#34;
  ]
}
</code></pre><p>Some words don&rsquo;t bring us any value. Let&rsquo;s skip them.</p>
<pre tabindex="0"><code>POST _analyze
{
  &#34;char_filter&#34;: [&#34;html_strip&#34;], 
  &#34;tokenizer&#34;:   &#34;standard&#34;,
  &#34;filter&#34;:      [
    {
      &#34;type&#34;:       &#34;stop&#34;,
      &#34;stopwords&#34;:  [ &#34;_english_&#34;]
    }
  ], 
  &#34;text&#34;:
  [ 
    &#34;I like when the &lt;strong&gt;quick&lt;/strong&gt; foxes jumps over lazy DOGS!&#34;,
    &#34;and &lt;strong&gt;fast&lt;/strong&gt;&#34;
  ]
}
</code></pre><p>We can also remove &ldquo;I&rdquo;, &ldquo;when&rdquo; and &ldquo;over&rdquo;.</p>
<pre tabindex="0"><code>POST _analyze
{
  &#34;char_filter&#34;: [&#34;html_strip&#34;], 
  &#34;tokenizer&#34;:   &#34;standard&#34;,
  &#34;filter&#34;:      [
    {
      &#34;type&#34;:       &#34;stop&#34;,
      &#34;ignore_case&#34;:true, 
      &#34;stopwords&#34;:  [ &#34;_english_&#34;, &#34;I&#34;, &#34;when&#34;, &#34;over&#34;]
    }
  ], 
  &#34;text&#34;:
  [ 
    &#34;I like when the &lt;strong&gt;quick&lt;/strong&gt; foxes jumps over lazy DOGS!&#34;,
    &#34;and &lt;strong&gt;fast&lt;/strong&gt;&#34;
  ]
}
</code></pre><p><code>DOGS</code> and <code>dogs</code> should match.</p>
<pre tabindex="0"><code>POST _analyze
{
  &#34;char_filter&#34;: [&#34;html_strip&#34;], 
  &#34;tokenizer&#34;:   &#34;standard&#34;,
  &#34;filter&#34;:      [
    {
      &#34;type&#34;:       &#34;stop&#34;,
      &#34;ignore_case&#34;:true, 
      &#34;stopwords&#34;:  [ &#34;_english_&#34;, &#34;I&#34;, &#34;when&#34;, &#34;over&#34;]
    },
    &#34;lowercase&#34;
  ], 
  &#34;text&#34;:
  [ 
    &#34;I like when the &lt;strong&gt;quick&lt;/strong&gt; foxes jumps over lazy DOGS!&#34;,
    &#34;and &lt;strong&gt;fast&lt;/strong&gt;&#34;
  ]
}
</code></pre><p><code>dog</code>, <code>dogs</code> and <code>fox</code>, <code>foxes</code> and <code>jump</code>, <code>jumps</code>, <code>jumping</code>, <code>jumped</code> should match. Let&rsquo;s use a <code>stemmer</code>.</p>
<pre tabindex="0"><code>POST _analyze
{
  &#34;char_filter&#34;: [&#34;html_strip&#34;], 
  &#34;tokenizer&#34;:   &#34;standard&#34;,
  &#34;filter&#34;:      [
    {
      &#34;type&#34;:       &#34;stop&#34;,
      &#34;ignore_case&#34;:true, 
      &#34;stopwords&#34;:  [ &#34;_english_&#34;, &#34;I&#34;, &#34;when&#34;, &#34;over&#34;]
    },
    &#34;lowercase&#34;,
    {
      &#34;type&#34;:       &#34;stemmer&#34;,
      &#34;language&#34;:   &#34;english&#34; 
    }
  ], 
  &#34;text&#34;:
  [ 
    &#34;jumping jumps jump jumped&#34;,
    &#34;I like when the &lt;strong&gt;quick&lt;/strong&gt; foxes jumps over lazy DOGS!&#34;,
    &#34;and &lt;strong&gt;fast&lt;/strong&gt;&#34;
  ]
}
</code></pre><h1 id="language-analyzer">Language analyzer</h1>
<pre tabindex="0"><code>GET /_analyze?pretty
{
  &#34;analyzer&#34;: &#34;hindi&#34;, 
  &#34;text&#34; : &#34;चाणक्य ने चंद्रगुप्त और बिंदूसार दोनों के लिए प्रधानमंत्री और राजनयिक सलाहकार के रूप में काम किया।&#34;
}
</code></pre><h2 id="lets-create-hindi-search-engine-गतयतर">Let&rsquo;s create Hindi search engine (गीतयंत्र)</h2>
<h3 id="create-mapping-1">Create mapping</h3>
<pre tabindex="0"><code>PUT geetyantra
{
  &#34;settings&#34;: {
    &#34;analysis&#34;: {
      &#34;analyzer&#34;: {
        &#34;geetyantra-analyzer&#34;:{
          &#34;type&#34;:&#34;hindi&#34;
        }
      }
    }
  },
  &#34;mappings&#34;: {
    &#34;properties&#34;: {
      &#34;adhyay&#34;: {&#34;type&#34;: &#34;integer&#34;},
      &#34;updesh&#34;: {&#34;type&#34;: &#34;text&#34;,&#34;analyzer&#34;: &#34;geetyantra-analyzer&#34;}
    }
  }
}
</code></pre><h3 id="insert-data">Insert data</h3>
<p>Taking data from 🙏<a href="https://hi.wikipedia.org/wiki/%E0%A4%B6%E0%A5%8D%E0%A4%B0%E0%A5%80%E0%A4%AE%E0%A4%A6%E0%A5%8D%E0%A4%AD%E0%A4%97%E0%A4%B5%E0%A4%A6%E0%A5%8D%E0%A4%97%E0%A5%80%E0%A4%A4%E0%A4%BE">विकिपीडिया-श्रीमद्भगवद्गीता</a></p>
<p>Lets insert some data like below:</p>
<pre tabindex="0"><code>POST geetyantra/_doc
{
  &#34;adhyay&#34;:1,
  &#34;updesh&#34;:&#34;कृष्ण ने अर्जुन की वह स्थिति देखकर जान लिया कि अर्जुन का शरीर ठीक है किंतु युद्ध आरंभ होने से पहले ही उस अद्भुत क्षत्रिय का मनोबल टूट चुका है। बिना मन के यह शरीर खड़ा नहीं रह स।&#34;
}

POST geetyantra/_doc
{
  &#34;adhyay&#34;:2,
  &#34;updesh&#34;:&#34;दूसरे अध्याय का नाम सांख्ययोग है। इसमें जीवन की दो प्राचीन संमानित परंपराओं का तर्कों द्वारा वर्णन आया है। अर्जुन को उस कृपण स्थिति में रोते देखकर कृष्ण ने उनका ध्यान दिलाया है कि इस प्रकार का क्लैव्य और हृदय की क्षुद्र दुर्बलता अर्जुन जैसे वीर के लिए उचित नहीं।&#34;
}

POST geetyantra/_doc
{
  &#34;adhyay&#34;:3,
  &#34;updesh&#34;:&#34;नित्य कर्म करने वाले की श्रेष्ठता&#34;
}

POST geetyantra/_doc
{
  &#34;adhyay&#34;:4,
  &#34;updesh&#34;:&#34;चौथे अध्याय में, जिसका नाम ज्ञान-कर्म-संन्यास-योग है, यह बाताया गया है कि ज्ञान प्राप्त करके कर्म करते हुए भी कर्मसंन्यास का फल किस उपाय से प्राप्त किया जा सकता है।&#34;,
  &#34;shloka&#34;:&#34;यदा यदा हि धर्मस्य ग्लानिर्भवति भारत,अभ्युत्थानमधर्मस्य तदात्मानं सृजाम्यहम्&#34;
}

POST geetyantra/_doc
{
  &#34;adhyay&#34;:5,
  &#34;updesh&#34;:&#34;ज्ञानी महापुरुष विद्या-विनययुक्त ब्राह्मण में और चाण्डाल में तथा गाय, हाथी एवं कुत्ते में भी समरूप परमात्मा को देखने वाले होते हैं।&#34;,
  &#34;shloka&#34;:&#34;विद्याविनयसंपन्ने ब्राह्मणे गवि हस्तिनि,शुनि चैव श्वपाके च पंडिता: समदर्शिन&#34;
}


POST geetyantra/_doc
{
  &#34;adhyay&#34;:6,
  &#34;updesh&#34;:&#34;छठा अध्याय आत्मसंयम योग है जिसका विषय नाम से ही प्रकट है। जितने विषय हैं उन सबसे इंद्रियों का संयम-यही कर्म और ज्ञान का निचोड़ है। सुख में और दुख में मन की समान स्थिति, इसे ही योग कहते हैं।&#34;
}

POST geetyantra/_doc
{
  &#34;adhyay&#34;:7,
  &#34;updesh&#34;:&#34;पंचतत्व, मन, बुद्धि भी मैं हूँ| मैं ही संसार की उत्पत्ति करता हूँ और विनाश भी मैं ही करता हूँ। मेरे भक्त चाहे जिस प्रकार भजें परन्तु अंततः मुझे ही प्राप्त होते हैं। मैं योगमाया से अप्रकट रहता हूँ और मुर्ख मुझे केवल साधारण मनुष्य ही समझते हैं।&#34;,
  &#34;shloka&#34;:&#34;यो यो यां यां तनुं भक्तः श्रद्धयार्चितुमिच्छति,तस्य तस्याचलां श्रद्धां तामेव विदधाम्यहम्&#34;
}

POST geetyantra/_doc
{
  &#34;adhyay&#34;:8,
  &#34;updesh&#34;:&#34;की संज्ञा अक्षर ब्रह्मयोग है। उपनिषदों में अक्षर विद्या का विस्तार हुआ। गीता में उस अक्षरविद्या का सार कह दिया गया है-अक्षर ब्रह्म परमं, अर्थात् परब्रह्म की संज्ञा अक्षर है। मनुष्य, अर्थात् जीव और शरीर की संयुक्त रचना का ही नाम अध्यात्म है।&#34;
}

POST geetyantra/_doc
{
  &#34;adhyay&#34;:9,
  &#34;updesh&#34;:&#34;को राजगुह्ययोग कहा गया है, अर्थात् यह अध्यात्म विद्या विद्याराज्ञी है और यह गुह्य ज्ञान सबमें श्रेष्ठ है। राजा शब्दका एक अर्थ मन भी था। अतएव मन की दिव्य शक्तिमयों को किस प्रकार ब्रह्ममय बनाया जाय, इसकी युक्ति ही राजविद्या है।&#34;
}

POST geetyantra/_doc
{
  &#34;adhyay&#34;:10,
  &#34;updesh&#34;:&#34;दसवें अध्याय का नाम विभूतियोग है। इसका सार यह है कि लोक में जितने देवता हैं, सब एक ही भगवान, की विभूतियाँ हैं, मनुष्य के समस्त गुण और अवगुण भगवान की शक्ति के ही रूप हैं।&#34;
}

POST geetyantra/_doc
{
  &#34;adhyay&#34;:11,
  &#34;updesh&#34;:&#34;का नाम विश्वरूपदर्शन योग है। इसमें अर्जुन ने भगवान का विश्वरूप देखा। विराट रूप का अर्थ है मानवीय धरातल और परिधि के ऊपर जो अनंत विश्व का प्राणवंत रचनाविधान है, उसका साक्षात दर्शन। विष्णु का जो चतुर्भुज रूप है, वह मानवीय धरातल पर सौम्यरूप है।&#34;
}

POST geetyantra/_doc
{
  &#34;adhyay&#34;:12,
  &#34;updesh&#34;:&#34;का नाम भक्ति योग है। जो जानने योग्य है। जिसको जानकर मनुष्य परमानन्द को प्राप्त हो जाता है अर्थात वो परमात्मा ही सत्य है ।।&#34;
}

POST geetyantra/_doc
{
  &#34;adhyay&#34;:13,
  &#34;updesh&#34;:&#34;में एक सीधा विषय क्षेत्र और क्षेत्रज्ञ का विचार है। यह शरीर क्षेत्र है, उसका जाननेवाला जीवात्मा क्षेत्रज्ञ है।&#34;
}

POST geetyantra/_doc
{
  &#34;adhyay&#34;:14,
  &#34;updesh&#34;:&#34;का नाम गुणत्रय विभाग योग है। यह विषय समस्त वैदिक, दार्शनिक और पौराणिक तत्वचिंतन का निचोड़ है-सत्व, रज, तम नामक तीन गुण-त्रिको की अनेक व्याख्याएँ हैं।&#34;
}

POST geetyantra/_doc
{
  &#34;adhyay&#34;:15,
  &#34;updesh&#34;:&#34;का नाम पुरुषोत्तमयोग है। इसमें विश्व का अश्वत्थ के रूप में वर्णन किया गया है। यह अश्वत्थ रूपी संसार महान विस्तारवाला है। देश और काल में इसका कोई अंत नहीं है।&#34;
}

POST geetyantra/_doc
{
  &#34;adhyay&#34;:16,
  &#34;updesh&#34;:&#34;में देवासुर संपत्ति का विभाग बताया गया है। आरंभ से ही ऋग्देव में सृष्टि की कल्पना दैवी और आसुरी शक्तियों के रूप में की गई है। &#34;
}

POST geetyantra/_doc
{
  &#34;adhyay&#34;:17,
  &#34;updesh&#34;:&#34;की संज्ञा श्रद्धात्रय विभाग योग है। इसका संबंध सत, रज और तम, इन तीन गुणों से ही है, अर्थात् जिसमें जिस गुण का प्रादुर्भाव होता है, उसकी श्रद्धा या जीवन की निष्ठा वैसी ही बन जाती है।&#34;
}

POST geetyantra/_doc
{
  &#34;adhyay&#34;:18,
  &#34;updesh&#34;:&#34;की संज्ञा मोक्षसंन्यास योग है। इसमें गीता के समस्त उपदेशों का सार एवं उपसंहार है। यहाँ पुन: बलपूर्वक मानव जीवन के लिए तीन गुणों का महत्व कहा गया है। पृथ्वी के मानवों में और स्वर्ग के देवताओं में कोई भी ऐसा नहीं जो प्रकृति के चलाए हुए इन तीन गुणों से बचा हो।&#34;
}
</code></pre><h3 id="search">Search</h3>
<pre tabindex="0"><code>
GET geetyantra/_search?size=20

GET geetyantra/_search
{
  &#34;query&#34;: {
    &#34;match&#34;: {
      &#34;updesh&#34;: &#34;अर्जुन&#34;
    }
  }
}

GET geetyantra/_search
{
  &#34;query&#34;: {
    &#34;match&#34;: {
      &#34;shloka&#34;: &#34;धर्मस्य&#34;
    }
  }
}

GET geetyantra/_search
{
  &#34;query&#34;: {
    &#34;multi_match&#34;: {
      &#34;query&#34;: &#34;श्रद्धा&#34;,
      &#34;fields&#34;: [&#34;shloka&#34;,&#34;updesh&#34;]
    }
  }
}

GET geetyantra/_search
{
  &#34;query&#34;: {
    &#34;match_phrase_prefix&#34;: {
      &#34;updesh&#34;: &#34;चौथे अध्याय में&#34;
    }
  }
}
</code></pre><h2 id="search-as-you-type">Search as you type</h2>
<p>Refer article <a href="https://ashish.one/blogs/search-as-you-type/">Search as you type</a>.</p>
]]></content:encoded>
    </item>
    <item>
      <title>How to build a Developer Profile - HugoConf2022</title>
      <link>https://ashish.one/blogs/build-developer-profile/</link>
      <pubDate>Mon, 27 Jun 2022 22:47:37 +0530</pubDate>
      <guid>https://ashish.one/blogs/build-developer-profile/</guid>
      <description>&lt;h1 id=&#34;just-a-thought-thought_balloon--&#34;&gt;Just a thought &amp;#x1f4ad;  &amp;hellip;&lt;/h1&gt;
&lt;p&gt;As a Developer, we keep learning &amp;amp; developing stuff. Sometimes we also find the solutions. Our stuff is distributed the same as our System architecture. We maintain different platforms like GitHub for projects, Medium for blogs, LinkedIn for profile, etc.&lt;/p&gt;
&lt;p&gt;All this stuff we want to share on a single platform but as a tech, I am lazy if you ask me to install some CMS and maintain all stuff over there. it is hard to switch from a black terminal &amp;#x1f4bb;  window to some UI &amp;#x1f605;&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h1 id="just-a-thought-thought_balloon--">Just a thought &#x1f4ad;  &hellip;</h1>
<p>As a Developer, we keep learning &amp; developing stuff. Sometimes we also find the solutions. Our stuff is distributed the same as our System architecture. We maintain different platforms like GitHub for projects, Medium for blogs, LinkedIn for profile, etc.</p>
<p>All this stuff we want to share on a single platform but as a tech, I am lazy if you ask me to install some CMS and maintain all stuff over there. it is hard to switch from a black terminal &#x1f4bb;  window to some UI &#x1f605;</p>
<p>As a developer I was always thinking can I write my blogs, article or notes in Vim? What if we can publish the blog the same as we do releases by hitting some commands.</p>
<p>In this gist, I am quickly going to give you some suggestions for tools that will help you to build your platform.</p>
<h1 id="the-requirement-memo">The Requirement &#x1f4dd;</h1>
<ul>
<li>Write a blog in any editor (For me its Vim)</li>
<li>Easy to publish</li>
<li>Developer Friendly</li>
<li>Lightweight and speed</li>
<li>Cost effective</li>
</ul>
<h1 id="lets-build-wrench">Let&rsquo;s Build &#x1f527;</h1>
<p>I was evaluating multiple tools while searching for a platform and found Hugo which is easy, fast, and handy as a developer. Hugo is an opensource static site generator which means you can write everything in Markdown and Hugo will generate the site accordingly. You need to know the basic Markdown syntax and you are good to go.</p>
<p>You can refer official <a href="https://gohugo.io/documentation/">hugo</a> document to get started.</p>
<p>Below is some tool that helped me to set up my platform.</p>
<hr>
<h1 id="theme">Theme</h1>
<p>Lots of themes are present which you can configure with your Hugo site. There are some common features across the themes and some themes provide the special features also. You can explore all themes here <a href="https://themes.gohugo.io/">themes.gohugo.io</a></p>
<p>I was looking for a simple theme which has a simple layout with menus, a dark theme, and tech friendly.</p>
<h2 id="papermod">PaperMod</h2>
<p>I have build my <a href="https://ashish.one">website</a> in <a href="https://github.com/adityatelange/hugo-PaperMod">PaperMod</a>. Few pointers why i choose:</p>
<h3 id="1-searchhttpsadityatelangegithubiohugo-papermodpostspapermodpapermod-featuressearch-page-mag">1. <a href="https://adityatelange.github.io/hugo-PaperMod/posts/papermod/papermod-features/#search-page">Search</a> &#x1f50d;</h3>
<p>PaperMod uses <a href="https://fusejs.io/getting-started/different-builds.html#explanation-of-different-builds">Fuse.js</a> Basic for search functionality.</p>
<h3 id="2-post-cover-image-tokyo_tower">2. Post Cover Image &#x1f5fc;</h3>
<p>It gives an easy option to add a cover image to your post.</p>
<h3 id="3-edit-link-for-post-pencil2">3. Edit link for post &#x270f;&#xfe0f;</h3>
<p><code>Suggest changes</code> option to ask viewers to contribute or Raise PR.</p>
<p>You can check more details about all features <a href="https://adityatelange.github.io/hugo-PaperMod/posts/papermod/papermod-features">here</a></p>
<h2 id="hyde-hydehttpsgithubcomhtr3nhyde-hyde"><a href="https://github.com/htr3n/hyde-hyde">hyde-hyde</a></h2>
<p>hyde-hyde I found a simple and easy theme if you want to get started with a simple menu and post. I chooses this because of its simplicity and then migrated to PaperMod.</p>
<h1 id="comments-speech_balloon">Comments &#x1f4ac;</h1>
<p>Once your audience starts reading your article, they would like to give feedback, suggestion and sometime it could be a discussion. You need someplace like <code>comments</code> where viewers can add their points to a particular article. The theme does not come with comments, for that you need to integrate the <code>comments</code> tool. Below are some suggestions you can explore:</p>
<h2 id="1-giscus">1. giscus</h2>
<p><a href="https://giscus.app/">Giscus</a> comments system powered by <a href="https://docs.github.com/en/discussions">GitHub Discussions</a>. Let visitors leave comments and reactions on your website via GitHub! As soon as your viewers comment on your article, it will create the discussion thread on Github Discussion. You can explore more about giscus on the official site.</p>
<h2 id="2-utterances">2. Utterances</h2>
<p><a href="https://github.com/utterance/utterances">utterances</a> lightweight comments system built powered by <a href="https://docs.github.com/en/issues/tracking-your-work-with-issues/about-issues">GitHub issues</a>. It will create an issue per article once anyone comments. All comments will be associated with a particular Github issue.</p>
<h2 id="3-disqus">3. DISQUS</h2>
<p><a href="https://disqus.com/">Disqus</a> is a blog comment hosting paid service for websites and online communities that use a networked platform. It also comes with social integration, social networks, user profiles, profile notifications, etc.</p>
<p>I migrated my comment system from utterances to giscus. As Github discussion is a proper tool for commenting, discussion, etc. Both are lightweight and you can choose accordingly.</p>
<h1 id="shortcodes">Shortcodes</h1>
<p>While developing the site with Hugo, Shortcodes are your friends. Always check if shortcodes are available for popular tools e.g. youtube, github gist, etc.</p>
<h1 id="hosting-cloud">Hosting &#x2601;&#xfe0f;</h1>
<p>After the site generation, you need to host your website somewhere.</p>
<p>Found <a href="https://pages.github.com/">Github pages</a> best place to host your static site. It allows you to manage your website the same way you manage your projects on github. Get started by creating a simple repository and pushing your source directory.</p>
<p>Check out all steps <a href="https://docs.github.com/en/pages/getting-started-with-github-pages/about-github-pages">here</a></p>
<p>Once you set up end to end, You can publish your blog or changes by just basic git commands i.e. <code>git add</code>, <code>git commit</code>, <code>git push</code>.</p>
<p>It will give you the same feeling as you are releasing some features for your project.</p>
<p>You can check more <a href="https://gohugo.io/hosting-and-deployment/">options</a> about hosting and deployment</p>
<p>I have hosted current website on <a href="https://github.com/ashishtiwari1993/ashish.one">github.com/ashishtiwari1993</a>.</p>
<h2 id="domain">Domain</h2>
<p>By default, Github pages assign the domain like <code>username.github.io</code> and you can access your site by visiting that subdomain. You can also setup the custom domain.</p>
<h1 id="speed-rocket">Speed &#x1f680;</h1>
<p>Almost 100% Page speed.</p>
<p><a href="https://pagespeed.web.dev/report?url=https://ashish.one">Pagespeed insights</a></p>
<hr>
<h1 id="tldr">tl;dr</h1>
<p>&#x2705; Platform - Hugo<br>
&#x2705; Theme - PaperMod<br>
&#x2705; Comment - giscus<br>
&#x2705; Hosting - Github Pages<br>
&#x2705; PageSpeed - 100%<br>
&#x2705; Cost - 100% Free</p>


    
    <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/fS9tndOl_BY?autoplay=0&controls=1&end=0&loop=0&mute=0&start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"
      ></iframe>
    </div>

]]></content:encoded>
    </item>
    <item>
      <title>Start a single node elastic cluster with Docker Compose</title>
      <link>https://ashish.one/blogs/elastic-docker-compose/</link>
      <pubDate>Wed, 08 Jun 2022 13:25:09 +0530</pubDate>
      <guid>https://ashish.one/blogs/elastic-docker-compose/</guid>
      <description>&lt;h1 id=&#34;introduction&#34;&gt;Introduction&lt;/h1&gt;
&lt;p&gt;In this gist, we will quickly try to spin Elastic stacks with Docker containers. We are going to use &lt;a href=&#34;https://docs.docker.com/compose/&#34;&gt;docker-compose&lt;/a&gt;. You can learn more about &lt;a href=&#34;https://www.docker.com/&#34;&gt;Docker&lt;/a&gt; &amp;amp; &lt;a href=&#34;https://docs.docker.com/compose/&#34;&gt;Docker Compose&lt;/a&gt;, Which will help you to understand the flow.&lt;/p&gt;
&lt;h1 id=&#34;prerequisite&#34;&gt;Prerequisite&lt;/h1&gt;
&lt;p&gt;Tested on the below configuration.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;docker:&lt;code&gt;Docker version 20.10.16, build aa7e414&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;docker-compose:&lt;code&gt;Docker version 20.10.16, build aa7e414&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id=&#34;cluster&#34;&gt;Cluster&lt;/h1&gt;
&lt;p&gt;This setup will include&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Elasticsearch&lt;/li&gt;
&lt;li&gt;Kibana&lt;/li&gt;
&lt;li&gt;Logstash&lt;/li&gt;
&lt;li&gt;APM&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id=&#34;setup&#34;&gt;Setup&lt;/h1&gt;
&lt;p&gt;Clone repo:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;git clone https://github.com/ashishtiwari1993/elastic-docker.git
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;cd elastic-docker
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Make changes in &lt;code&gt;.env&lt;/code&gt; file.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h1 id="introduction">Introduction</h1>
<p>In this gist, we will quickly try to spin Elastic stacks with Docker containers. We are going to use <a href="https://docs.docker.com/compose/">docker-compose</a>. You can learn more about <a href="https://www.docker.com/">Docker</a> &amp; <a href="https://docs.docker.com/compose/">Docker Compose</a>, Which will help you to understand the flow.</p>
<h1 id="prerequisite">Prerequisite</h1>
<p>Tested on the below configuration.</p>
<ul>
<li>docker:<code>Docker version 20.10.16, build aa7e414</code></li>
<li>docker-compose:<code>Docker version 20.10.16, build aa7e414</code></li>
</ul>
<h1 id="cluster">Cluster</h1>
<p>This setup will include</p>
<ul>
<li>Elasticsearch</li>
<li>Kibana</li>
<li>Logstash</li>
<li>APM</li>
</ul>
<h1 id="setup">Setup</h1>
<p>Clone repo:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>git clone https://github.com/ashishtiwari1993/elastic-docker.git
</span></span><span style="display:flex;"><span>cd elastic-docker
</span></span></code></pre></div><p>Make changes in <code>.env</code> file.</p>
<h1 id="start-the-cluster">Start the cluster</h1>
<h2 id="start">Start</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>docker-compose up -d
</span></span></code></pre></div><p>Just visit to <code>localhost:5601</code>. You should see a kibana login page.</p>
<h2 id="stop">Stop</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>docker-compose down
</span></span></code></pre></div><h2 id="stop-with-deleting-network-containers-and-volumes">Stop with deleting network, containers and volumes</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>docker-compose down -v
</span></span></code></pre></div><h1 id="access-stacks">Access stacks</h1>
<h2 id="elasticsearch">Elasticsearch</h2>
<h3 id="access-via-curl-from-host-machine">Access via <code>curl</code> from host machine</h3>
<h4 id="copy-cacrt-file">Copy <code>ca.crt</code> file</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>docker cp elastic-docker_es01_1:/usr/share/elasticsearch/config/certs/ca/ca.crt /tmp/
</span></span></code></pre></div><h4 id="curl-command">Curl command</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>curl --cacert /tmp/ca.crt -u elastic:pass@123 https://localhost:9200
</span></span></code></pre></div><h2 id="logstash">Logstash</h2>
<ol>
<li>You need to have pipeline configuration files on <code>LOGSTASH_PIPELINE_PATH</code> location. If there will be no file, Logstash will throw an error and get exit.</li>
</ol>
<h1 id="note">NOTE</h1>
<blockquote>
<p>You can simply comment other stacks which is not needed. For example if you want to just run Elasticsearch &amp; Kibana, Just comment the APM or other stack specification.</p>
</blockquote>
]]></content:encoded>
    </item>
    <item>
      <title>Parsing Custom log format to the Elasticsearch</title>
      <link>https://ashish.one/blogs/parsing-custom-log-format-to-the-elasticsearch/</link>
      <pubDate>Fri, 29 Apr 2022 01:24:55 +0530</pubDate>
      <guid>https://ashish.one/blogs/parsing-custom-log-format-to-the-elasticsearch/</guid>
      <description>&lt;h1 id=&#34;introduction&#34;&gt;Introduction&lt;/h1&gt;
&lt;p&gt;As a developer, you need to log everything it may be info, error or debug logs, etc. There are multiple types of log formats like Common log, JSON log, etc. and there are already solutions available in an elastic stack like filebeat to read JSON logs and push them to elasticsearch.&lt;/p&gt;
&lt;p&gt;There can be cases where you need to log the data according to your convenience which will not be any standard log format. Or sometimes you just need to dump the log in an unstructured way but you need to have it in a structured format if you want to analyze those.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h1 id="introduction">Introduction</h1>
<p>As a developer, you need to log everything it may be info, error or debug logs, etc. There are multiple types of log formats like Common log, JSON log, etc. and there are already solutions available in an elastic stack like filebeat to read JSON logs and push them to elasticsearch.</p>
<p>There can be cases where you need to log the data according to your convenience which will not be any standard log format. Or sometimes you just need to dump the log in an unstructured way but you need to have it in a structured format if you want to analyze those.</p>
<p>In this article, we are going to see how we can parse custom logs of any format into Elasticsearch. Elasticsearch provides the ingest pipeline with grok processor which will be able to match any unstructured log.</p>
<h1 id="overview">Overview</h1>
<h2 id="ingest-pipeline">Ingest Pipeline</h2>
<p>Elasticsearch gives <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html">ingest pipeline</a> where it let you perform different types of operations or data transformations before indexing the data. The pipeline consists of a series of various processors.</p>
<p>Each processor in the pipeline takes input and produces the output. That output goes as input to the next processor.</p>
<p>Like below, After converting into lowercase letters by &ldquo;lowercase processor&rdquo; it sends the same string as input to the &ldquo;split processor&rdquo;.</p>
<p>Example</p>
<pre tabindex="0"><code>{&#34;date&#34;:&#34;HELLO - WORLD&#34;} Input → |  lowercase processor ({&#34;date&#34;:&#34;hello - world&#34;}) → split processor ({&#34;date&#34;:&#34;hello world&#34;})   |  → Index
</code></pre><p>You can check more about ingest <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html">pipeline</a> and <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/processors.html">processors</a>.</p>
<h2 id="grok-processor">Grok Processor</h2>
<p><a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/grok-processor.html">Grok Processor</a> allows you to extract structured data from the ingested value on the specific field. Grok Processor works with grok patterns.</p>
<p>Let&rsquo;s suppose you have the following document</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;Ip&#34;</span>:<span style="color:#e6db74">&#34;1.2.3.4&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;country&#34;</span>:<span style="color:#e6db74">&#34;India&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;log&#34;</span>:<span style="color:#e6db74">&#34;LEVEL:ERROR,method:fetchUser(),message:user not found&#34;</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>You can mention the field name (Ex. <code>log</code>) where you want to apply a grok processor. The Grok processor uses the Grok pattern.</p>
<h2 id="grok-pattern">Grok pattern</h2>
<p>Grok pattern is the regular expression which is the alias of some of the predefined expressions which can be reused.</p>
<p>Below is some sample grok patterns:</p>
<pre tabindex="0"><code>HOSTNAME \b(?:[0-9A-Za-z][0-9A-Za-z-]{0,62})(?:\.(?:[0-9A-Za-z][0-9A-Za-z-]{0,62}))*(\.?|\b)
USERNAME [a-zA-Z0-9._-]+
USER %{USERNAME}
SPACE \s*
</code></pre><p>Here <code>HOSTNAME</code>, <code>USERNAME</code>, <code>USER</code> &amp; <code>SPACE</code> are Grok pattern names.</p>
<p>I can directly use <code>SPACE</code> label to define regex for space instead of a regular pattern like <code>\s*</code>. Also, the Grok pattern can be reused as the same as <code>USERNAME</code>.</p>
<h3 id="pattern-list">Pattern list</h3>
<p>You can find all pattern list on the below link:</p>
<p><a href="https://github.com/elastic/elasticsearch/tree/8.1/libs/grok/src/main/resources/patterns">https://github.com/elastic/elasticsearch/tree/8.1/libs/grok/src/main/resources/patterns</a></p>
<p>You can select any folder and explore all the patterns.</p>
<p><strong>Grok pattern</strong>: <a href="https://github.com/elastic/elasticsearch/blob/master/libs/grok/src/main/resources/patterns/ecs-v1/grok-patterns">https://github.com/elastic/elasticsearch/blob/master/libs/grok/src/main/resources/patterns/ecs-v1/grok-patterns</a></p>
<h1 id="the-flow">The flow</h1>
<ol>
<li>Create &amp; Test Ingest Pipeline</li>
<li>Index custom data</li>
</ol>
<p>Lets create the pipeline with a grok processor which is going to parse the <code>message</code> field with the document below.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;Ip&#34;</span>:<span style="color:#e6db74">&#34;1.2.3.4&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;country&#34;</span>:<span style="color:#e6db74">&#34;India&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;message&#34;</span>:<span style="color:#e6db74">&#34;LEVEL:ERROR,method:fetchUser(),message:user not found,code:123&#34;</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>I would like to extract the below data from message field and index into elasticsearch,</p>
<pre tabindex="0"><code>&#34;method_name&#34; : &#34;fetchUser&#34;,
&#34;log_level&#34; : &#34;ERROR&#34;,
&#34;response_code&#34; : &#34;123&#34;,
&#34;message&#34; : &#34;user not found&#34;
</code></pre><h2 id="create--test-ingest-pipeline">Create &amp; Test Ingest Pipeline</h2>
<h3 id="syntax">Syntax</h3>
<pre tabindex="0"><code>%{SYNTAX:ID}
</code></pre><p><strong>SYNTAX</strong>: It is the pattern name.<br>
<strong>ID</strong>: It is the key name of the document.</p>
<p>Data need to parse</p>
<pre tabindex="0"><code>LEVEL:ERROR,method:fetchUser(),message:user not found
</code></pre><p>Let&rsquo;s match some of the grok patterns from the below file
<a href="https://github.com/elastic/elasticsearch/blob/master/libs/grok/src/main/resources/patterns/ecs-v1/grok-patterns">https://github.com/elastic/elasticsearch/blob/master/libs/grok/src/main/resources/patterns/ecs-v1/grok-patterns</a></p>
<pre tabindex="0"><code>ERROR = %{LOGLEVEL:log_level}
fetchUser = %{WORD:method_name}
user not found = %{GREEDYDATA:message}
123 = code:(?&lt;response_code&gt;(?:[+-]?(?:[0-9]+)))
</code></pre><p><strong>Data</strong></p>
<pre tabindex="0"><code>LEVEL:ERROR,method:fetchUser(),message:user not found
</code></pre><p><strong>Final Pattern</strong></p>
<pre tabindex="0"><code>&#34;LEVEL:%{LOGLEVEL:log_level},method:%{WORD:method_name}\\(\\),message:%{GREEDYDATA:message},code:(?&lt;response_code&gt;(?:[+-]?(?:[0-9]+)))&#34;
</code></pre><blockquote>
<p>Note: You can add your own regex as well. For example, I have added regex for <code>code</code>.</p>
</blockquote>
<h2 id="test-pipeline">Test pipeline</h2>
<p>For testing above pattern or pipeline we can use <a href="https://github.com/elastic/elasticsearch/blob/master/libs/grok/src/main/resources/patterns/ecs-v1/grok-patterns">Simulate Pipeline API</a> like below:</p>
<h4 id="_simulate">_simulate</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>POST /_ingest/pipeline/_simulate?pretty
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;pipeline&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;description&#34;</span> : <span style="color:#e6db74">&#34;testing grok processor&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;processors&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;grok&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;field&#34;</span>: <span style="color:#e6db74">&#34;log&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;patterns&#34;</span>: <span style="color:#f92672">[</span><span style="color:#e6db74">&#34;LEVEL:%{LOGLEVEL:log_level},method:%{WORD:method_name}\\(\\),message:%{GREEDYDATA:message},code:(?&lt;response_code&gt;(?:[+-]?(?:[0-9]+)))&#34;</span><span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;docs&#34;</span>:<span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;_source&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;log&#34;</span>: <span style="color:#e6db74">&#34;LEVEL:ERROR,method:fetchUser(),message:user not found,code:123&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><h4 id="response">Response</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;docs&#34;</span> : [
</span></span><span style="display:flex;"><span>    {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;doc&#34;</span> : {
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_index&#34;</span> : <span style="color:#e6db74">&#34;_index&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_id&#34;</span> : <span style="color:#e6db74">&#34;_id&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_source&#34;</span> : {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;response_code&#34;</span> : <span style="color:#e6db74">&#34;123&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;log&#34;</span> : <span style="color:#e6db74">&#34;LEVEL:ERROR,method:fetchUser(),message:user not found,code:123&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;method_name&#34;</span> : <span style="color:#e6db74">&#34;fetchUser&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;log_level&#34;</span> : <span style="color:#e6db74">&#34;ERROR&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;message&#34;</span> : <span style="color:#e6db74">&#34;user not found&#34;</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_ingest&#34;</span> : {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;timestamp&#34;</span> : <span style="color:#e6db74">&#34;2022-04-29T14:20:59.454111422Z&#34;</span>
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>  ]
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>As you can see we got the desired output. Now let&rsquo;s save the pipeline.</p>
<h3 id="save-pipeline">Save pipeline</h3>
<p>Pipeline can be saved using <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html">_ingest/pipeline</a> API.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>PUT /_ingest/pipeline/custom_log?pretty
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;description&#34;</span> : <span style="color:#e6db74">&#34;testing grok processor&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;processors&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;grok&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;field&#34;</span>: <span style="color:#e6db74">&#34;log&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;patterns&#34;</span>: <span style="color:#f92672">[</span><span style="color:#e6db74">&#34;LEVEL:%{LOGLEVEL:log_level},method:%{WORD:method_name}\\(\\),message:%{GREEDYDATA:message},code:(?&lt;response_code&gt;(?:[+-]?(?:[0-9]+)))&#34;</span><span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p><strong>Custom_log</strong>:  It is the pipeline name. We need to specify the pipeline name while indexing the data.</p>
<h2 id="index-custom-data">Index custom data</h2>
<p>Now let&rsquo;s index some data with the same pipeline which we created.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>POST data-stream/_doc?pipeline<span style="color:#f92672">=</span>custom_log
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;log&#34;</span> : <span style="color:#e6db74">&#34;LEVEL:INFO,method:addUser(),message:user added successfully.,code:200&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>POST data-stream/_doc?pipeline<span style="color:#f92672">=</span>custom_log
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;log&#34;</span> : <span style="color:#e6db74">&#34;LEVEL:DEBUG,method:deleteUser(),message:user_id notfound.,code:433&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>POST data-stream/_doc?pipeline<span style="color:#f92672">=</span>custom_log
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;log&#34;</span> : <span style="color:#e6db74">&#34;LEVEL:ERROR,method:fetchUser(),message:Database connection timeout,code:567&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>Check all data</p>
<pre tabindex="0"><code>GET data-stream/_search?pretty
</code></pre><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;took&#34;</span> : <span style="color:#ae81ff">898</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;timed_out&#34;</span> : <span style="color:#66d9ef">false</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;_shards&#34;</span> : {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;total&#34;</span> : <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;successful&#34;</span> : <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;skipped&#34;</span> : <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;failed&#34;</span> : <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;hits&#34;</span> : {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;total&#34;</span> : {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;value&#34;</span> : <span style="color:#ae81ff">3</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;relation&#34;</span> : <span style="color:#e6db74">&#34;eq&#34;</span>
</span></span><span style="display:flex;"><span>    },
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;max_score&#34;</span> : <span style="color:#ae81ff">1.0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;hits&#34;</span> : [
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_index&#34;</span> : <span style="color:#e6db74">&#34;data-stream&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_id&#34;</span> : <span style="color:#e6db74">&#34;3460dYABYeDE95hG23XJ&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_score&#34;</span> : <span style="color:#ae81ff">1.0</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_source&#34;</span> : {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;response_code&#34;</span> : <span style="color:#e6db74">&#34;200&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;log&#34;</span> : <span style="color:#e6db74">&#34;LEVEL:INFO,method:addUser(),message:user added successfully.,code:200&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;method_name&#34;</span> : <span style="color:#e6db74">&#34;addUser&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;log_level&#34;</span> : <span style="color:#e6db74">&#34;INFO&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;message&#34;</span> : <span style="color:#e6db74">&#34;user added successfully.&#34;</span>
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>      },
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_index&#34;</span> : <span style="color:#e6db74">&#34;data-stream&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_id&#34;</span> : <span style="color:#e6db74">&#34;Kwi2dYABbuPmoOiCSUjL&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_score&#34;</span> : <span style="color:#ae81ff">1.0</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_source&#34;</span> : {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;response_code&#34;</span> : <span style="color:#e6db74">&#34;433&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;log&#34;</span> : <span style="color:#e6db74">&#34;LEVEL:DEBUG,method:deleteUser(),message:user_id notfound.,code:433&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;method_name&#34;</span> : <span style="color:#e6db74">&#34;deleteUser&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;log_level&#34;</span> : <span style="color:#e6db74">&#34;DEBUG&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;message&#34;</span> : <span style="color:#e6db74">&#34;user_id notfound.&#34;</span>
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>      },
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_index&#34;</span> : <span style="color:#e6db74">&#34;data-stream&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_id&#34;</span> : <span style="color:#e6db74">&#34;LAi4dYABbuPmoOiCmUgb&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_score&#34;</span> : <span style="color:#ae81ff">1.0</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_source&#34;</span> : {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;response_code&#34;</span> : <span style="color:#e6db74">&#34;567&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;log&#34;</span> : <span style="color:#e6db74">&#34;LEVEL:ERROR,method:fetchUser(),message:Database connection timeout,code:567&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;method_name&#34;</span> : <span style="color:#e6db74">&#34;fetchUser&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;log_level&#34;</span> : <span style="color:#e6db74">&#34;ERROR&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;message&#34;</span> : <span style="color:#e6db74">&#34;Database connection timeout&#34;</span>
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>    ]
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><h1 id="parsing-common-log-format">Parsing common log format</h1>
<p>Common log format is standard format for logging which is used by webservers and system log generators etc.</p>
<p>Let&rsquo;s say we having below log:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>97.92.139.153 <span style="color:#ae81ff">1254</span> ashishtiwari <span style="color:#f92672">[</span>04/Mar/2022:15:18:55 +0530<span style="color:#f92672">]</span> <span style="color:#e6db74">&#34;GET /niches HTTP/1.1&#34;</span> <span style="color:#ae81ff">201</span> <span style="color:#ae81ff">2322</span>
</span></span></code></pre></div><h2 id="grok-pattern-1">Grok Pattern</h2>
<p><img loading="lazy" src="/img/misc/parse-custom-log.png" alt="Common log format grok pattern"  />
</p>
<h2 id="final-grok-pattern">Final Grok Pattern</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>%<span style="color:#f92672">{</span>IPORHOST:ip<span style="color:#f92672">}</span> %<span style="color:#f92672">{</span>USER:user_id<span style="color:#f92672">}</span> %<span style="color:#f92672">{</span>USERNAME:username<span style="color:#f92672">}</span> <span style="color:#ae81ff">\\</span><span style="color:#f92672">[</span>%<span style="color:#f92672">{</span>HTTPDATE:date<span style="color:#f92672">}</span><span style="color:#ae81ff">\\</span><span style="color:#f92672">]</span> <span style="color:#ae81ff">\&#34;</span>%<span style="color:#f92672">{</span>WORD:request.method<span style="color:#f92672">}</span> %<span style="color:#f92672">{</span>URIPATH:request.path<span style="color:#f92672">}</span> %<span style="color:#f92672">{</span>URIPROTO:request.proto<span style="color:#f92672">}</span>/%<span style="color:#f92672">{</span>NUMBER:request.http_version<span style="color:#f92672">}</span><span style="color:#ae81ff">\&#34;</span> %<span style="color:#f92672">{</span>NUMBER:request.response<span style="color:#f92672">}</span> %<span style="color:#f92672">{</span>NUMBER:request.size_bytes<span style="color:#f92672">}</span>
</span></span></code></pre></div><h2 id="_simulate-1">_simulate</h2>
<p>Lets simulate the pipeline with above grok pattern</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>POST /_ingest/pipeline/_simulate?pretty
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;pipeline&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;description&#34;</span> : <span style="color:#e6db74">&#34;testing grok processor&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;processors&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;grok&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;field&#34;</span>: <span style="color:#e6db74">&#34;log&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;patterns&#34;</span>: <span style="color:#f92672">[</span><span style="color:#e6db74">&#34;%{IPORHOST:ip} %{USER:user_id} %{USERNAME:username} \\[%{HTTPDATE:date}\\] \&#34;%{WORD:request.method} %{URIPATH:request.path} %{URIPROTO:request.proto}/%{NUMBER:request.http_version}\&#34; %{NUMBER:request.response} %{NUMBER:request.size_bytes}&#34;</span><span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;docs&#34;</span>:<span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;_source&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;log&#34;</span>: <span style="color:#e6db74">&#34;97.92.139.153 1254 ashishtiwari [04/Mar/2022:15:18:55 +0530] \&#34;GET /niches HTTP/1.1\&#34; 201 2322&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><h2 id="response-1">Response</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;docs&#34;</span> : [
</span></span><span style="display:flex;"><span>    {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;doc&#34;</span> : {
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_index&#34;</span> : <span style="color:#e6db74">&#34;_index&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_id&#34;</span> : <span style="color:#e6db74">&#34;_id&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_source&#34;</span> : {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;date&#34;</span> : <span style="color:#e6db74">&#34;04/Mar/2022:15:18:55 +0530&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;request&#34;</span> : {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;path&#34;</span> : <span style="color:#e6db74">&#34;/niches&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;size_bytes&#34;</span> : <span style="color:#e6db74">&#34;2322&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;method&#34;</span> : <span style="color:#e6db74">&#34;GET&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;response&#34;</span> : <span style="color:#e6db74">&#34;201&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;proto&#34;</span> : <span style="color:#e6db74">&#34;HTTP&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;http_version&#34;</span> : <span style="color:#e6db74">&#34;1.1&#34;</span>
</span></span><span style="display:flex;"><span>          },
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;log&#34;</span> : <span style="color:#e6db74">&#34;&#34;&#34;97.92.139.153 1254 ashishtiwari [04/Mar/2022:15:18:55 +0530] &#34;</span><span style="color:#960050;background-color:#1e0010">GET</span> <span style="color:#960050;background-color:#1e0010">/niches</span> <span style="color:#960050;background-color:#1e0010">HTTP/</span><span style="color:#ae81ff">1.1</span><span style="color:#e6db74">&#34; 201 2322&#34;&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;user_id&#34;</span> : <span style="color:#e6db74">&#34;1254&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;ip&#34;</span> : <span style="color:#e6db74">&#34;97.92.139.153&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;username&#34;</span> : <span style="color:#e6db74">&#34;ashishtiwari&#34;</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_ingest&#34;</span> : {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;timestamp&#34;</span> : <span style="color:#e6db74">&#34;2022-04-29T14:42:51.765427484Z&#34;</span>
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>  ]
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>As we can see it successfully parsed the data. You can save the pipeline and index the data as shown on the above steps.</p>
<p>Similarly you can parse any log format with Grok pattern.</p>
<h1 id="demo">Demo</h1>
<p>You can also check the demo on the below link where I presented how you can parse common log format using ingest pipeline and grok processor.</p>
<p><a href="https://ashish.one/talks/devops-conf-2022/">https://ashish.one/talks/devops-conf-2022/</a></p>
<h1 id="conclusion">Conclusion</h1>
<p>We have seen how we can parse any types of log format into elasticsearch with the help of ingest pipeline &amp; grok processor. You can also use this ingest pipeline with filebeat or logstash. Where you just need to specify the pipeline name.</p>
<p>Feel free to put in comments if you have any doubts.</p>
]]></content:encoded>
    </item>
    <item>
      <title>[Part -1] Search as you type</title>
      <link>https://ashish.one/blogs/search-as-you-type/</link>
      <pubDate>Fri, 18 Mar 2022 01:24:55 +0530</pubDate>
      <guid>https://ashish.one/blogs/search-as-you-type/</guid>
      <description>&lt;h1 id=&#34;introduction&#34;&gt;Introduction&lt;/h1&gt;
&lt;p&gt;In this blog, we will try to understand how “Search as you type” works and Quickly setup one demo using some sample data.
You must have seen various websites like eCommerce, food apps, etc. where you just start typing &amp;amp; simultaneously relevant options start displaying as suggestions and autocomplete. We will try to achieve somewhat the same feature.
Search as you type
Elasticsearch gives this specific mapping type which you can simply set to a specific field where you want to perform this kind of search.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h1 id="introduction">Introduction</h1>
<p>In this blog, we will try to understand how “Search as you type” works and Quickly setup one demo using some sample data.
You must have seen various websites like eCommerce, food apps, etc. where you just start typing &amp; simultaneously relevant options start displaying as suggestions and autocomplete. We will try to achieve somewhat the same feature.
Search as you type
Elasticsearch gives this specific mapping type which you can simply set to a specific field where you want to perform this kind of search.</p>
<h1 id="why-search_as_you_type">Why <code>search_as_you_type</code>?</h1>
<p>No need to think about what kind of functionality like analyzer, tokenizer, etc. you have to apply to achieve this. It automatically handles everything in the backend by producing necessary terms on which you can query efficiently.</p>
<p>You can simply create mapping like the below example:</p>
<h2 id="create-index">Create Index</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>PUT products
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;mappings&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;properties&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;description&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;type&#34;</span>: <span style="color:#e6db74">&#34;search_as_you_type&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><h2 id="insert-sample-data">Insert sample data</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>POST products/_doc/
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;description&#34;</span>: <span style="color:#e6db74">&#34;best jogging shoes for men&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><h2 id="how-is-data-indexed-">How is data indexed ?</h2>
<p><code>search_as_you_type</code> mapping creates 4 types of fields in the backend.</p>
<h3 id="field-1-description">Field 1: <code>description</code></h3>
<p>It will produce the terms according to the default analyzer if no analyzer is defined i.e. <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-standard-analyzer.html">standard analyzer</a>.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>[
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jogging&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;shoes&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;for&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;men&#34;</span>
</span></span><span style="display:flex;"><span>]
</span></span></code></pre></div><h3 id="field-2-description_2gram">Field 2: <code>description._2gram</code></h3>
<p>This will use a <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-shingle-tokenfilter.html">shingle token filter</a> and produce the terms with shingle size 2.
This means a shingle token filter produces the token by concatenating the adjacent token. You can find more <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-shingle-tokenfilter.html">here</a>.</p>
<p>This operation will perform on all the terms which are created on the <code>description</code> field and it will produce the below terms.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>[ 
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best jogging&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jogging shoes&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;shoes for&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;for men&#34;</span>
</span></span><span style="display:flex;"><span>]
</span></span></code></pre></div><h3 id="field-3-description_3gram">Field 3: <code>description._3gram</code></h3>
<p>This will also use a shingle token filter and produce the terms with shingle size 3. This means it will concatenate 3 adjacent tokens like below.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>[
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best jogging shoes&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jogging shoes for&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;shoes for men&#34;</span>
</span></span><span style="display:flex;"><span>]
</span></span></code></pre></div><h3 id="field-4-description_index_prefix">Field 4: <code>description._index_prefix</code></h3>
<p>This will apply an <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-edgengram-tokenizer.html">edge n gram token filter</a> on the field <code>description._3gram</code> which means it will split terms (words) of <code>description._3gram</code> to a small substring that will start from the edge.
You can have a look at the terms below.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>[
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;b&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;be&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;bes&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best &#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best j&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best jo&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best jog&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best jogg&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best joggi&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best joggin&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best jogging&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best jogging &#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best jogging s&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best jogging sh&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best jogging sho&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best jogging shoe&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;best jogging shoes&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;j&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jo&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jog&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jogg&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;joggi&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;joggin&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jogging&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jogging &#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jogging s&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jogging sh&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jogging sho&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jogging shoe&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jogging shoes&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jogging shoes &#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jogging shoes f&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jogging shoes fo&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;jogging shoes for&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;s&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;sh&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;sho&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;shoe&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;shoes&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;shoes &#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;shoes f&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;shoes fo&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;shoes for&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;shoes for &#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;shoes for m&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;shoes for me&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;shoes for men&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;f&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;fo&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;for&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;for &#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;for m&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;for me&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;for men&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;for men &#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;m&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;me&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;men&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;men &#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;men  &#34;</span>
</span></span><span style="display:flex;"><span>]
</span></span></code></pre></div><p>As you noticed the token limit is up to 3 words only because <code>description._3gram</code> has generated 3 word tokens only.</p>
<h1 id="search-query">Search Query</h1>
<h2 id="multi_match"><code>multi_match</code></h2>
<p>We will use a <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html">multi_match</a> query here. Because we want to look up on each subfield for a perfect match.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>GET products/_search
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;query&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;multi_match&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;query&#34;</span>: <span style="color:#e6db74">&#34;jogging&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;fields&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;description&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;description._2gram&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;description._3gram&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>The above query is going to search the term <code>&quot;jogging&quot;</code> on all 3 subfields which are specified in <code>fields[]</code>.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;took&#34;</span> : <span style="color:#ae81ff">2</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;timed_out&#34;</span> : <span style="color:#66d9ef">false</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;_shards&#34;</span> : {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;total&#34;</span> : <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;successful&#34;</span> : <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;skipped&#34;</span> : <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;failed&#34;</span> : <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;hits&#34;</span> : {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;total&#34;</span> : {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;value&#34;</span> : <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;relation&#34;</span> : <span style="color:#e6db74">&#34;eq&#34;</span>
</span></span><span style="display:flex;"><span>    },
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;max_score&#34;</span> : <span style="color:#ae81ff">0.2876821</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;hits&#34;</span> : [
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_index&#34;</span> : <span style="color:#e6db74">&#34;products&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_id&#34;</span> : <span style="color:#e6db74">&#34;TSNNiX8BYh0NLleBiu4u&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_score&#34;</span> : <span style="color:#ae81ff">0.2876821</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_source&#34;</span> : {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;description&#34;</span> : <span style="color:#e6db74">&#34;best jogging shoes for men&#34;</span>
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>    ]
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>Lets try with any substring (<code>jog</code>).</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>GET products/_search
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;query&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;multi_match&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;query&#34;</span>: <span style="color:#e6db74">&#34;jog&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;fields&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;description&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;description._2gram&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;description._3gram&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;took&#34;</span> : <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;timed_out&#34;</span> : <span style="color:#66d9ef">false</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;_shards&#34;</span> : {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;total&#34;</span> : <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;successful&#34;</span> : <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;skipped&#34;</span> : <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;failed&#34;</span> : <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;hits&#34;</span> : {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;total&#34;</span> : {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;value&#34;</span> : <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;relation&#34;</span> : <span style="color:#e6db74">&#34;eq&#34;</span>
</span></span><span style="display:flex;"><span>    },
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;max_score&#34;</span> : <span style="color:#66d9ef">null</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;hits&#34;</span> : [ ]
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>The result is empty. Because there is no term created with the name <strong><code>jog</code></strong> if you closely look at the above generated tokens on respective fields.</p>
<p>To solve this we need to use the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-bool-prefix-query.html">bool_prefix</a> query.</p>
<p><code>bool_prefix</code> analyze the input and constructs the bool query from the terms. But it puts the last term in the prefix query. For example, input is given as <code>men jogging s</code>, So it will produce terms like <code>[&quot;men&quot;,&quot;jogging&quot;,&quot;s&quot;]</code> but it will always perform a prefix query on the last term which is <code>&quot;s&quot;</code>. So documents will return where terms will match with <code>&quot;men&quot;</code> or <code>&quot;jogging&quot;</code> or any term which is starting with <code>&quot;s&quot;</code>.</p>
<p>Below is the query which will give you the desired output.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>GET products/_search
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;query&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;multi_match&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;query&#34;</span>: <span style="color:#e6db74">&#34;jog&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;type&#34;</span>: <span style="color:#e6db74">&#34;bool_prefix&#34;</span>, 
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;fields&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;description&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;description._2gram&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;description._3gram&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;took&#34;</span> : <span style="color:#ae81ff">4</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;timed_out&#34;</span> : <span style="color:#66d9ef">false</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;_shards&#34;</span> : {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;total&#34;</span> : <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;successful&#34;</span> : <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;skipped&#34;</span> : <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;failed&#34;</span> : <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>  },
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;hits&#34;</span> : {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;total&#34;</span> : {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;value&#34;</span> : <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;relation&#34;</span> : <span style="color:#e6db74">&#34;eq&#34;</span>
</span></span><span style="display:flex;"><span>    },
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;max_score&#34;</span> : <span style="color:#ae81ff">1.0</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;hits&#34;</span> : [
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_index&#34;</span> : <span style="color:#e6db74">&#34;products&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_id&#34;</span> : <span style="color:#e6db74">&#34;TSNNiX8BYh0NLleBiu4u&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_score&#34;</span> : <span style="color:#ae81ff">1.0</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;_source&#34;</span> : {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;description&#34;</span> : <span style="color:#e6db74">&#34;best jogging shoes for men&#34;</span>
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>    ]
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>Here when we make a prefix query on the root field (<code>description</code>) or any subfields, It will rewrite the query as a <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html">term</a> query on <code>description._index_prefix</code> field.</p>
<p>This matches more efficiently because prefixes up to 3 words are already created as the terms as shown in the above.</p>
<blockquote>
<p>Note: This query will search for terms irrespective of order. For example, if we search for <code>jogging men</code>, This will also give the result because it will search for both the terms <code>jogging</code> or <code>men</code>. In most of the cases this query (multi_match + bool_prefix) is recommended because the end user can search for any string like <code>shoes</code> or <code>shoes for men</code> or <code>jogging shoes</code> etc.</p>
</blockquote>
<h2 id="what-if-you-want-to-search-with-strict-prefix-order">What if you want to search with strict prefix order?</h2>
<p>You can use <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html">match_phrase_prefix</a>, It will strictly match input from prefix in the same order only. So input like “men best” won’t return anything. Whereas you will get results with the previous one.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>GET products/_search
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;query&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;match_phrase_prefix&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;description&#34;</span>: <span style="color:#e6db74">&#34;best jogging s&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>It will return documents where the term&rsquo;s prefix will be matched with “best jogging s”. Sometimes it can provide confusing results. You can check more about <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html#match-phrase-prefix-autocomplete">match_phrase_prefix</a>.</p>
<h1 id="demo">Demo</h1>
<p>Let’s take a practical experience of how it is going to work.</p>
<h1 id="search-as-you-type-elasticsearch">Search As You Type (Elasticsearch)</h1>
<p>Demo code and sample employees data to implement the &ldquo;Search as you type&rdquo; feature on elasticsearch.</p>
<p>Written the middleware API in <code>python</code> using <a href="https://flask.palletsprojects.com/en/2.0.x/">flask</a>. Used <a href="https://jquery.com/">JQuery</a> for javascript operations.</p>
<h2 id="installation">Installation</h2>
<p>Assuming you have successfully installed <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html">Elasticsearch</a> and <a href="https://www.elastic.co/guide/en/kibana/current/install.html">Kibana</a> on your machine and it is working perfectly. Kindly refer respective installation document.</p>
<p>OR</p>
<p>You can run <a href="https://cloud.elastic.co/registration">Elasticsearch on the cloud</a> with a few clicks.</p>
<h3 id="install-python3--pip3">Install Python3 &amp; pip3</h3>
<ol>
<li>Refer <a href="https://www.python.org/downloads/">Document</a> to install <code>python3</code> &amp; <code>pip3</code> on your system.</li>
<li>Install <code>flask</code></li>
</ol>
<pre tabindex="0"><code>pip3 install flask
</code></pre><ol start="3">
<li>Install <code>elasticsearch</code> package</li>
</ol>
<pre tabindex="0"><code>pip3 install elasticsearch
</code></pre><h3 id="git-clone">git Clone</h3>
<pre tabindex="0"><code>git clone https://github.com/ashishtiwari1993/search_as_you_type.git
cd search_as_you_type
</code></pre><h3 id="create-index-and-load-data">Create Index and load data</h3>
<p>Make sure Elasticsearch and kibana are up and running fine on your machine.</p>
<h4 id="create-index-1">Create Index</h4>
<pre tabindex="0"><code>PUT /sayt?pretty
{
  &#34;mappings&#34;: {
    &#34;properties&#34;: {
      &#34;first_name&#34;: {
        &#34;type&#34;: &#34;search_as_you_type&#34;
      },
      &#34;last_name&#34;: {
        &#34;type&#34;: &#34;search_as_you_type&#34;
      },
      &#34;street_address&#34;: {
        &#34;type&#34;: &#34;search_as_you_type&#34;
      },
      &#34;company&#34;: {
        &#34;type&#34;: &#34;search_as_you_type&#34;
      },
      &#34;email&#34;: {
        &#34;type&#34;: &#34;search_as_you_type&#34;
      }
    }
  }
}
</code></pre><h4 id="load-sample-data">Load sample data</h4>
<p>Sample <a href="https://github.com/ashishtiwari1993/search_as_you_type/blob/main/data.json">data.json</a> file is given which need to load with the help of <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html">bulk API</a>.</p>
<pre tabindex="0"><code>curl -s -H &#34;Content-Type: application/x-ndjson&#34; -XPOST &#34;localhost:9200/_bulk&#34; --data-binary &#34;@data.json&#34;
</code></pre><p>Do not forget to change the elasticsearch&rsquo;s endpoint.</p>
<h3 id="run-apipy--test">Run <code>api.py</code> &amp; test</h3>
<p>Open <code>api.py</code> and change elasticsearch endpoint accordingly.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-py" data-lang="py"><span style="display:flex;"><span>es <span style="color:#f92672">=</span> Elasticsearch(<span style="color:#e6db74">&#34;http://localhost:9200&#34;</span>)
</span></span></code></pre></div><h4 id="start-api-server">Start API Server</h4>
<pre tabindex="0"><code>python3 api.py
</code></pre><p>This will start the API service on port <code>5001</code>.</p>
<p>Open <code>index.html</code> on your browser.</p>
]]></content:encoded>
    </item>
    <item>
      <title>Parse custom logs in Elasticsearch using grok_pattern</title>
      <link>https://ashish.one/talks/devops-conf-2022/</link>
      <pubDate>Sun, 06 Mar 2022 14:30:32 +0530</pubDate>
      <guid>https://ashish.one/talks/devops-conf-2022/</guid>
      <description>&lt;h1 id=&#34;introduction&#34;&gt;Introduction&lt;/h1&gt;
&lt;p&gt;In the talk, Quickly showed how you can use the &lt;a href=&#34;https://www.elastic.co/beats/metricbeat&#34;&gt;metricbeat&lt;/a&gt; to check system health. With a few clicks, you can start monitoring your infra.&lt;/p&gt;
&lt;p&gt;Another demo shows, How you can parse your custom unstructured logs to Elasticsearch. There is some utility already available for predefined logs format like json, apache, nginx and system logs etc.&lt;/p&gt;
&lt;p&gt;But if you have different requirement where you need to parse a different types of log format , You can parse using &lt;a href=&#34;https://www.elastic.co/guide/en/elasticsearch/reference/master/grok-processor.html&#34;&gt;Grok processor&lt;/a&gt;.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h1 id="introduction">Introduction</h1>
<p>In the talk, Quickly showed how you can use the <a href="https://www.elastic.co/beats/metricbeat">metricbeat</a> to check system health. With a few clicks, you can start monitoring your infra.</p>
<p>Another demo shows, How you can parse your custom unstructured logs to Elasticsearch. There is some utility already available for predefined logs format like json, apache, nginx and system logs etc.</p>
<p>But if you have different requirement where you need to parse a different types of log format , You can parse using <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/grok-processor.html">Grok processor</a>.</p>
<p>Also explained how you can read custom logs from log files in real time and ingest to Elasticsearch.</p>
<h1 id="slides">Slides</h1>
<div id="Container"
 style="padding-bottom:56.25%; position:relative; display:block; width: 100%">
 <iframe id="googleSlideIframe"
  width="100%" height="100%"
  src="https://docs.google.com/presentation/d/e/2PACX-1vQtGa1x8-WMwWX8MTMZ-8GdJDMmiro4dNwcIE5HHmj1oGaSs88znwGf-W8bwUSANkIRQkeMZnh8KfWs/embed?start=false&amp;loop=false&amp;delayms=3000"
  frameborder="0" allowfullscreen=""
  style="position:absolute; top:0; left: 0"></iframe>
</div>

<h2 id="talk-video">Talk Video</h2>


    
    <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/owyv9sQE7q8?start=4856&end=9427?autoplay=0&controls=1&end=0&loop=0&mute=0&start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"
      ></iframe>
    </div>

<h4 id="feel-free-to-comment-below-if-you-have-any-doubts-or-suggestion-about-this-talk">Feel free to comment below, If you have any doubts or suggestion about this talk.</h4>
]]></content:encoded>
    </item>
    <item>
      <title>Deploy Elasicsearch on Azure cloud</title>
      <link>https://ashish.one/talks/deploy_elastic_on_azure/</link>
      <pubDate>Sat, 29 Jan 2022 19:24:45 +0000</pubDate>
      <guid>https://ashish.one/talks/deploy_elastic_on_azure/</guid>
      <description>&lt;h1 id=&#34;introduction&#34;&gt;Introduction&lt;/h1&gt;
&lt;h2 id=&#34;what-this-talk-is-all-about-&#34;&gt;What this talk is all about ?&lt;/h2&gt;
&lt;p&gt;The purpose of the talk is to give a short overview of Elastic solutions &amp;amp; Elastic stacks. In the demo shown, how you can deploy elasticsearch instance on Microsoft Azure.&lt;/p&gt;
&lt;p&gt;Also, it gives an idea to use the elastic cloud to manage the elasticsearch instance which deployed on the Azure cloud. You can also create deployment on elastic cloud (&lt;a href=&#34;https://cloud.elastic.co&#34;&gt;cloud.elastic.co&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;In the demo, Successfully shipped the metric data of the local system (my MacBook) to the newly deployed elasticsearch instance and explored the dashboard on kibana.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h1 id="introduction">Introduction</h1>
<h2 id="what-this-talk-is-all-about-">What this talk is all about ?</h2>
<p>The purpose of the talk is to give a short overview of Elastic solutions &amp; Elastic stacks. In the demo shown, how you can deploy elasticsearch instance on Microsoft Azure.</p>
<p>Also, it gives an idea to use the elastic cloud to manage the elasticsearch instance which deployed on the Azure cloud. You can also create deployment on elastic cloud (<a href="https://cloud.elastic.co">cloud.elastic.co</a>).</p>
<p>In the demo, Successfully shipped the metric data of the local system (my MacBook) to the newly deployed elasticsearch instance and explored the dashboard on kibana.</p>
<h2 id="slides">Slides</h2>
<div id="Container"
 style="padding-bottom:56.25%; position:relative; display:block; width: 100%">
 <iframe id="googleSlideIframe"
  width="100%" height="100%"
  src="https://docs.google.com/presentation/d/e/2PACX-1vR9COL0Pod4Hdhc3OlkIPorb-UM0DtbhSgcqQajOYV789jbmRYsffyIRVR0cFCnm8eu80sF8-khLc0K/embed?start=false&amp;loop=false&amp;delayms=3000"
  frameborder="0" allowfullscreen=""
  style="position:absolute; top:0; left: 0"></iframe>
</div>

<h2 id="talk-video">Talk Video</h2>


    
    <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/O2HdAA5o1i4?autoplay=0&controls=1&end=0&loop=0&mute=0&start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"
      ></iframe>
    </div>

<h4 id="feel-free-to-comment-below-if-you-have-any-doubts-or-suggestion-about-this-talk">Feel free to comment below, If you have any doubts or suggestion about this talk.</h4>
]]></content:encoded>
    </item>
    <item>
      <title>Arch Linux Installation Challenges</title>
      <link>https://ashish.one/blogs/arch-linux-installation-challenges/</link>
      <pubDate>Fri, 07 Jan 2022 07:20:29 +0000</pubDate>
      <guid>https://ashish.one/blogs/arch-linux-installation-challenges/</guid>
      <description>Arch linux installation challenges</description>
      <content:encoded><![CDATA[<p><img loading="lazy" src="/img/arch-linux-installation/arch-linux.jpeg" alt="arch linux login screen"  />
</p>
<h1 id="introduction">Introduction</h1>
<p>This article is not containing the detailed procedure for installation but listed some challenges which you can face while installing the arch Linux. Arch Linux is one of the Linux distributions, Which gives you full control over your application and OS. You have complete freedom to install or what to keep. Unlike the other distribution like Ubuntu, Centos, etc. It doesn&rsquo;t come with pre-loaded applications or software.</p>
<p>Though Arch wiki has a detailed explanation of the installation process I faced some challenges whose solution was not easily available. I am listing a few here and will keep updating this post as I move forward.</p>
<p>In this post I am not going to cover the installation steps, You will get a better explanation on the arch wiki.</p>
<h1 id="machine-configuration">Machine Configuration</h1>
<h2 id="hardware">Hardware</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>RAM: 2GB
</span></span><span style="display:flex;"><span>Disk: <span style="color:#ae81ff">500</span>
</span></span></code></pre></div><h2 id="bios-configuration">BIOS configuration</h2>
<p>Secure boot: <code>disabled</code><br>
Legacy boot: <code>enabled</code><br>
Boot Mode: <code>UEFI</code></p>
<h1 id="challenges">Challenges</h1>
<h2 id="1-what-should-be-my-disk-partition-">1. What should be my disk partition ?</h2>
<h3 id="11-check-boot-mode">1.1 Check Boot mode</h3>
<p>You need to check <a href="https://wiki.archlinux.org/title/Installation_guide">installation guide</a>, Refer step <strong>Verify the boot mode</strong>.</p>
<p>In a live environment, you need to check first what is your boot mode.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>ls /sys/firmware/efi/efivars
</span></span></code></pre></div><p>If the command shows the directory without error, then the system is booted in UEFI mode. If the directory does not exist, the system may be booted in BIOS (or CSM) mode.</p>
<p>So my machine&rsquo;s boot mode is UEFI.</p>
<h3 id="12-how-to-create-partitions">1.2 How to create partitions?</h3>
<p>I would recommend using <code>cfdisk</code> command to create the partition. Which gives you good visualization.</p>
<p>My SCSI Disk is <code>dev/sda</code>.</p>
<h3 id="13-types-of-partition">1.3 Types of Partition</h3>
<p>You need to create 3 types of partition as shown below:</p>
<table>
  <thead>
      <tr>
          <th>Mount Point</th>
          <th>Partition</th>
          <th>Partition Type</th>
          <th>Size</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>/mnt/boot</td>
          <td>/dev/sda1</td>
          <td>EFI System</td>
          <td>1G</td>
      </tr>
      <tr>
          <td>[SWAP]</td>
          <td>/dev/sda2</td>
          <td>LINUX Swap</td>
          <td>4G</td>
      </tr>
      <tr>
          <td>/mnt</td>
          <td>/dev/sda3</td>
          <td>LINUX Filesystem</td>
          <td>460G</td>
      </tr>
  </tbody>
</table>
<p>Here on my machine i have created 3 partition name <code>dev/sda1</code>, <code>dev/sda2</code>, <code>dev/sda3</code>. This name can be different.</p>
<p>This is how you need to create the partition with the help of the <code>cfdisk</code> command.</p>
<h3 id="14-mount-the-partition">1.4 Mount the partition</h3>
<h4 id="format-the-partition">Format the partition</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>mkfs.ext4 /dev/sda3
</span></span><span style="display:flex;"><span>mkswap /dev/sda2
</span></span><span style="display:flex;"><span>mkfs.fat -F <span style="color:#ae81ff">32</span> /dev/sda1
</span></span></code></pre></div><h4 id="mount-the-partition">Mount the partition</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>mount /dev/sda3 /mnt
</span></span><span style="display:flex;"><span>mount /dev/sda1 /mnt/boot
</span></span><span style="display:flex;"><span>swapon /dev/sda2
</span></span></code></pre></div><h2 id="2-install-bootloader">2. Install Bootloader</h2>
<p>I have decided to install a grub bootloader on my machine. You can decide on this <a href="https://wiki.archlinux.org/title/Arch_boot_process">wiki page</a>.</p>
<h3 id="21-install-grub">2.1 Install GRUB</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>pacman -S grub
</span></span></code></pre></div><h3 id="22-generate-grub-config">2.2 Generate Grub config</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>grub-install --target<span style="color:#f92672">=</span>x86_64-efi --efi-directory<span style="color:#f92672">=</span>/boot --bootloader-id<span style="color:#f92672">=</span>GRUB
</span></span></code></pre></div><h3 id="23-reboot-the-system">2.3 Reboot the system</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>exit
</span></span><span style="display:flex;"><span>umount /dev/sda3
</span></span><span style="display:flex;"><span>reboot
</span></span></code></pre></div><h2 id="3-how-to-login-again-with-live-bootable-arch-device-usbcd-etc">3. How to login again with Live bootable Arch device (USB/CD etc.)</h2>
<p>Sometimes we need to install some package with a live environment only. In such a case, you can prefer these steps.</p>
<p>Attach the live bootable device and choose the specific device in the boot order. Once you are logged in, Just perform the below commands.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>mount /dev/sda3 /mnt
</span></span><span style="display:flex;"><span>mount /dev/sda1 /mnt/boot
</span></span><span style="display:flex;"><span>swapon /dev/sda2
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>arch-chroot /mnt
</span></span></code></pre></div><p>Once you are in Than you can perform any operation on your installed Arch OS.</p>
<h2 id="4-install-networkmanager">4. Install NetworkManager</h2>
<p>Please refer to challenge #3 to log in with the live environment. Once you successfully log in, Perform the below commands:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>pacman -S NetworkManager
</span></span><span style="display:flex;"><span>systemctl start NetworkManager
</span></span><span style="display:flex;"><span>systemclt enable NetworkManager
</span></span></code></pre></div><p>Simply check with ping if you connected with a LAN connection.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>ping google.com
</span></span></code></pre></div><blockquote>
<p>Note: Please start and enable the Network Manager after reboot. It will not start on first time login.</p>
</blockquote>
<h2 id="5-install-broadcom-wireless">5. Install Broadcom Wireless</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>pacman -S linux-headers
</span></span><span style="display:flex;"><span>pacman -S broadcom-wl-dkms
</span></span></code></pre></div><p>Reboot the system.</p>
<h2 id="6-desktop-environment-arch">6. Desktop Environment Arch</h2>
<p>To run any desktop environment, Need to install Display Manager. First, we will install LXDM (display manager).</p>
<h3 id="61-lxdm">6.1 LXDM</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>pacman -S lxdm
</span></span><span style="display:flex;"><span>systemctl start lxdm
</span></span><span style="display:flex;"><span>systemctl enable lxdm
</span></span></code></pre></div><h3 id="62-lxde">6.2 LXDE</h3>
<p>LXDE is a lightweight desktop. As my system has 2GB RAM, I have tried this.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>pacman -S lxde
</span></span></code></pre></div><p>Reboot the system.</p>
<h3 id="63-xfce4">6.3 XFCE4</h3>
<p>Xfce is a lightweight and modular desktop environment currently based on GTK 3. To provide a complete user experience, it includes a window manager, a file manager, desktop and panel.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>pacman -S xfce4 xfce4-goodies
</span></span></code></pre></div><p>Edit <code>lxdm.conf</code></p>
<p>Edit below line</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>session<span style="color:#f92672">=</span>/usr/bin/startlxfce4
</span></span></code></pre></div><p>Reboot the system.</p>
<h2 id="7-connect-to-wifi">7. Connect to WIFI</h2>
<p>You need to install Network Manager and wireless driver first. You can refer step 4 &amp; 5.</p>
<p>Once done with proper installation you can connect to wifi using:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>nmtui
</span></span></code></pre></div><h2 id="8-stuck-on-grub-window-while-booting-on-arch-linux">8. Stuck on GRUB window while booting on arch linux</h2>
<p><img loading="lazy" src="/img/arch-linux-installation/grub-window.jpeg" alt="arch linux login screen"  />
</p>
<p>It seems my bootloader was not configured properly. Re Attached the live bootable device and perform steps 3 and then 2.</p>
<p>Reboot the system.</p>
<h2 id="9-error--time--timed-out-waiting-for-device-devdiskby-uuid">9. Error: [ TIME ] Timed out waiting for device /dev/disk/by-uuid/</h2>
<p><img loading="lazy" src="/img/arch-linux-installation/partition-fail.jpeg" alt="arch linux login screen"  />
</p>
<p>Please perform step 3.</p>
<p>Check UUID of partitions</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>lsblk -l
</span></span></code></pre></div><p>Cross-check whether the above UUIDs and mentioned UUIDs in <code>/etc/fstab</code> should be the same.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>vim /etc/fstab
</span></span></code></pre></div><p>Update UUID accordingly on the above file. Save and exit.</p>
<p>Reboot the system.</p>
]]></content:encoded>
    </item>
    <item>
      <title>Get start with BugBounty, Pentest and Security Researcher</title>
      <link>https://ashish.one/blogs/get-start-with-bugbounty-pentest-security-researcher/</link>
      <pubDate>Sun, 20 Jun 2021 13:53:50 +0530</pubDate>
      <guid>https://ashish.one/blogs/get-start-with-bugbounty-pentest-security-researcher/</guid>
      <description>&lt;p&gt;I have always been in confusion about how to get started with security or pentest or somehow with a bug bounty. There are tons of resources available on the internet.&lt;/p&gt;
&lt;h2 id=&#34;the-fact&#34;&gt;The Fact&lt;/h2&gt;
&lt;p&gt;The fact is there is no hard and fast rule or there is no standard course by following which you will get the tag of a security expert.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;There is no defined way to become a security researcher.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>I have always been in confusion about how to get started with security or pentest or somehow with a bug bounty. There are tons of resources available on the internet.</p>
<h2 id="the-fact">The Fact</h2>
<p>The fact is there is no hard and fast rule or there is no standard course by following which you will get the tag of a security expert.</p>
<blockquote>
<p>There is no defined way to become a security researcher.</p>
</blockquote>
<p>Here at the end, I am also going to give you some resources about the get started but to be honest it will not help until you start with a practice or use it in your day-to-day life for learning purposes.</p>
<h2 id="so-what-missing">So what missing?</h2>
<p>Resources will get the directions for learning. Let’s say you got one blog where the blogger explains everything steps by step and You decided to complete it in 7 days. Your approach SHOULD NOT be that once you finish with the whole tutorial you should start with researching it won’t help or probably you must have forgotten the things which you learned on day 1.</p>
<h2 id="the-approach">The Approach</h2>
<p>Start performing practical from the first day. Whatever your learning start implementing those. Try to find the smallest loopholes. And trust me you won’t get it on Day 1. But with the practice, you will become to know how to find or where to find.</p>
<h2 id="where-to-do-practice">Where to do practice?</h2>
<p>You can use any Bugbounty side where lots of products, apps, websites get listed to find bugs, vulnerabilities, etc. You can also use CTF (Capture the flag). I will not go in deep with these terminologies because you can find better explanations on google. You will also get a better guide on how to start with these platforms.</p>
<p>Don’t Forget your practice will give you a real security expert badge. Keep practicing.</p>
<h2 id="some-resources-to-get-start">Some resources to get start</h2>
<ul>
<li>
<p><a href="https://github.com/nahamsec/Resources-for-Beginner-Bug-Bounty-Hunters">https://github.com/nahamsec/Resources-for-Beginner-Bug-Bounty-Hunters</a></p>
</li>
<li>
<p><a href="https://whoami.securitybreached.org/2019/06/03/guide-getting-started-in-bug-bounty-hunting/">https://whoami.securitybreached.org/2019/06/03/guide-getting-started-in-bug-bounty-hunting/</a></p>
</li>
<li>
<p><a href="https://infosecwriteups.com/guide-to-basic-recon-bug-bounties-recon-728c5242a115">https://infosecwriteups.com/guide-to-basic-recon-bug-bounties-recon-728c5242a115</a></p>
</li>
<li>
<p>Pentesting for n00bs is ELI5 hacking, designed for beginners who have never walked through a hack before. All 10 episodes:</p>
</li>
</ul>
<p>Ep 1 - Legacy: <a href="https://youtu.be/JZN3JhoAdWo">https://youtu.be/JZN3JhoAdWo</a></p>
<p>Ep 2 - Lame: <a href="https://youtu.be/ntBkyid_u8Y">https://youtu.be/ntBkyid_u8Y</a></p>
<p>Ep 3 - Blue: <a href="https://youtu.be/xLI7OialKk4">https://youtu.be/xLI7OialKk4</a></p>
<p>Ep 4 - Devel: <a href="https://youtu.be/ODUDau7BPSY">https://youtu.be/ODUDau7BPSY</a></p>
<p>Ep. 5 - Jerry: <a href="https://youtu.be/nF14K2VAVtw">https://youtu.be/nF14K2VAVtw</a></p>
<p>Ep. 6 - Nibbles: <a href="https://youtu.be/8ulnQVFHcOE">https://youtu.be/8ulnQVFHcOE</a></p>
<p>Ep. 7 - Optimum: <a href="https://youtu.be/bTxnobhJ_b8">https://youtu.be/bTxnobhJ_b8</a></p>
<p>Ep. 8 - Bashed: <a href="https://youtu.be/5406MfOfXBc">https://youtu.be/5406MfOfXBc</a></p>
<p>Ep. 9 - Grandpa: <a href="https://youtu.be/3aASluoJ-iM">https://youtu.be/3aASluoJ-iM</a></p>
<p>Ep. 10 - Netmon: <a href="https://youtu.be/8k-8aVwS0fk">https://youtu.be/8k-8aVwS0fk</a></p>
<p>Please feel free to post your doubt or suggestions below :slight_smile:</p>
<p>Thanks</p>
]]></content:encoded>
    </item>
    <item>
      <title>SPF Lookup in Go</title>
      <link>https://ashish.one/blogs/spf-lookup-in-go/</link>
      <pubDate>Mon, 03 Aug 2020 00:38:53 +0530</pubDate>
      <guid>https://ashish.one/blogs/spf-lookup-in-go/</guid>
      <description>&lt;p&gt;In this gist, We will check how we can extract SPF records in Go.&lt;/p&gt;
&lt;h2 id=&#34;prerequisite&#34;&gt;Prerequisite&lt;/h2&gt;
&lt;h3 id=&#34;go-version&#34;&gt;Go version&lt;/h3&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ go version
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;go version go1.13 linux/amd64
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;dependency&#34;&gt;Dependency&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://github.com/miekg/dns&#34;&gt;DNS Library(https://github.com/miekg/dns)&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;install-dependency&#34;&gt;Install dependency&lt;/h2&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ go get github.com/miekg/dns 
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;spflookupgo&#34;&gt;spfLookup.go&lt;/h2&gt;
&lt;script src=&#34;https://gist.github.com/ashishtiwari1993/ea5da5581ae2c56f3e25f8509155bd37.js&#34;&gt;&lt;/script&gt;

&lt;p&gt;Here you can change &lt;code&gt;nameserver&lt;/code&gt; according to your requirement. I have specified here google&amp;rsquo;s name server (&lt;code&gt;8.8.8.8&lt;/code&gt;). You can also use cloudflare&amp;rsquo;s nameserver &lt;a href=&#34;https://1.1.1.1&#34;&gt;(1.1.1.1)&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;You can make any DNS query with &lt;code&gt;miekg/dns&lt;/code&gt; library. In the above script, we have looked up &lt;code&gt;TXT&lt;/code&gt; Records and then we have searched for a string containing &lt;code&gt;v=spf1&lt;/code&gt;.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>In this gist, We will check how we can extract SPF records in Go.</p>
<h2 id="prerequisite">Prerequisite</h2>
<h3 id="go-version">Go version</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ go version
</span></span><span style="display:flex;"><span>go version go1.13 linux/amd64
</span></span></code></pre></div><h3 id="dependency">Dependency</h3>
<p><a href="https://github.com/miekg/dns">DNS Library(https://github.com/miekg/dns)</a></p>
<h2 id="install-dependency">Install dependency</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ go get github.com/miekg/dns 
</span></span></code></pre></div><h2 id="spflookupgo">spfLookup.go</h2>
<script src="https://gist.github.com/ashishtiwari1993/ea5da5581ae2c56f3e25f8509155bd37.js"></script>

<p>Here you can change <code>nameserver</code> according to your requirement. I have specified here google&rsquo;s name server (<code>8.8.8.8</code>). You can also use cloudflare&rsquo;s nameserver <a href="https://1.1.1.1">(1.1.1.1)</a></p>
<h2 id="conclusion">Conclusion</h2>
<p>You can make any DNS query with <code>miekg/dns</code> library. In the above script, we have looked up <code>TXT</code> Records and then we have searched for a string containing <code>v=spf1</code>.</p>
]]></content:encoded>
    </item>
    <item>
      <title>Shipping Golang logs with ELKB stack</title>
      <link>https://ashish.one/blogs/shipping-golang-logs-with-elkb-stack/</link>
      <pubDate>Sat, 06 Jun 2020 23:31:33 +0530</pubDate>
      <guid>https://ashish.one/blogs/shipping-golang-logs-with-elkb-stack/</guid>
      <description>&lt;p&gt;&lt;img loading=&#34;lazy&#34; src=&#34;https://ashish.one/img/go-elk-logs/banner.png&#34; alt=&#34;Go ship logs with ELK Banner&#34;  /&gt;
&lt;/p&gt;
&lt;h2 id=&#34;goal-of-this-blog&#34;&gt;Goal of this blog&lt;/h2&gt;
&lt;p&gt;In this blog, I am going to show you how easily we can write logs to the files in Golang. As well as we are going  to store all logs on elasticsearch with EKB (Elasticsearch, Kibana, Beats).&lt;/p&gt;
&lt;h2 id=&#34;why-elkb-stack-&#34;&gt;Why ELKB stack ?&lt;/h2&gt;
&lt;p&gt;Logs are very important for debugging, reporting, insights etc. In today&amp;rsquo;s tech world, We uses multiple cloud servers, private servers etc. Which consist of lots of different applications, scripts, programs, daemons, services and they generate their logs too. It is very difficult to go to each server and check all log files in case of debugging or to generate any insights or reporting.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p><img loading="lazy" src="/img/go-elk-logs/banner.png" alt="Go ship logs with ELK Banner"  />
</p>
<h2 id="goal-of-this-blog">Goal of this blog</h2>
<p>In this blog, I am going to show you how easily we can write logs to the files in Golang. As well as we are going  to store all logs on elasticsearch with EKB (Elasticsearch, Kibana, Beats).</p>
<h2 id="why-elkb-stack-">Why ELKB stack ?</h2>
<p>Logs are very important for debugging, reporting, insights etc. In today&rsquo;s tech world, We uses multiple cloud servers, private servers etc. Which consist of lots of different applications, scripts, programs, daemons, services and they generate their logs too. It is very difficult to go to each server and check all log files in case of debugging or to generate any insights or reporting.</p>
<p>In my case I used to go to every server and perform <code>grep</code>  on log files.</p>
<p>ELKB Gives you an easy setup to move all yours logs into one central Place which is Elasticsearch &amp; With a beautiful kibana interface, You can visualize all your logs. You can also make various types of dashboards.</p>
<p>This is a very small use case I am going to convert but you can find lots of big problem solving use cases on the internet about ELKB.</p>
<p>I will not go much deeper about ELKB stack. You can find a wonderful explanation on elastic.co.</p>
<h2 id="two-parts">Two Parts:</h2>
<ol>
<li>Write JSON logs to the file in Go</li>
<li>Shift All JSON logs on Elasticsearch</li>
</ol>
<h2 id="my-configuration">My Configuration</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>OS: ubuntu 18.04
</span></span><span style="display:flex;"><span>Go version: go version go1.13 linux/amd64
</span></span><span style="display:flex;"><span>Elasticsearch version: 7.7.1
</span></span><span style="display:flex;"><span>Filebeat version: filebeat version 7.7.1 <span style="color:#f92672">(</span>amd64<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Kibana version: 7.7.1
</span></span></code></pre></div><h2 id="1-write-json-logs-to-the-file-in-go">1. Write JSON logs to the file in Go</h2>
<p>I am assuming you have already installed Go on your machine. If not then you can refer to the installation guide <a href="https://golang.org/doc/install">here</a>.</p>
<h3 id="my-golang-version">My Golang version:</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>go version go1.13 linux/amd64
</span></span></code></pre></div><h3 id="logrushttpsgodocorggithubcomsirupsenlogrus"><a href="https://godoc.org/github.com/sirupsen/logrus">Logrus</a></h3>
<p>This is a wonderful package available to write logs. Below is the short example of using logrus package:</p>
<h4 id="1-install-logrus-package">1. Install Logrus package</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>go install github.com/sirupsen/logru
</span></span></code></pre></div><h4 id="2-create-loggo-and-paste-the-below-code">2. Create <code>log.go</code> and paste the below code</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-go" data-lang="go"><span style="display:flex;"><span><span style="color:#f92672">package</span> <span style="color:#a6e22e">main</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> (
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;os&#34;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">log</span> <span style="color:#e6db74">&#34;github.com/sirupsen/logrus&#34;</span>
</span></span><span style="display:flex;"><span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">func</span> <span style="color:#a6e22e">init</span>() {
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">f</span>, <span style="color:#a6e22e">_</span> <span style="color:#f92672">:=</span> <span style="color:#a6e22e">os</span>.<span style="color:#a6e22e">OpenFile</span>(<span style="color:#e6db74">&#34;/tmp/go_logs/example.log&#34;</span>, <span style="color:#a6e22e">os</span>.<span style="color:#a6e22e">O_RDWR</span>|<span style="color:#a6e22e">os</span>.<span style="color:#a6e22e">O_CREATE</span>|<span style="color:#a6e22e">os</span>.<span style="color:#a6e22e">O_APPEND</span>, <span style="color:#ae81ff">0666</span>)
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">log</span>.<span style="color:#a6e22e">SetFormatter</span>(<span style="color:#f92672">&amp;</span><span style="color:#a6e22e">log</span>.<span style="color:#a6e22e">JSONFormatter</span>{})
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">log</span>.<span style="color:#a6e22e">SetOutput</span>(<span style="color:#a6e22e">f</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">func</span> <span style="color:#a6e22e">main</span>() {
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">log</span>.<span style="color:#a6e22e">WithFields</span>(<span style="color:#a6e22e">log</span>.<span style="color:#a6e22e">Fields</span>{
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;event&#34;</span>: <span style="color:#e6db74">&#34;create_profile&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;user_id&#34;</span>:   <span style="color:#ae81ff">10</span>,
</span></span><span style="display:flex;"><span>  }).<span style="color:#a6e22e">Info</span>(<span style="color:#e6db74">&#34;This is an info message.&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">log</span>.<span style="color:#a6e22e">WithFields</span>(<span style="color:#a6e22e">log</span>.<span style="color:#a6e22e">Fields</span>{
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;event&#34;</span>: <span style="color:#e6db74">&#34;delete_profile&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;user_id&#34;</span>: <span style="color:#ae81ff">11</span>,
</span></span><span style="display:flex;"><span>  }).<span style="color:#a6e22e">Warn</span>(<span style="color:#e6db74">&#34;This is a warning message.&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">log</span>.<span style="color:#a6e22e">WithFields</span>(<span style="color:#a6e22e">log</span>.<span style="color:#a6e22e">Fields</span>{
</span></span><span style="display:flex;"><span>		<span style="color:#e6db74">&#34;event&#34;</span> : <span style="color:#e6db74">&#34;edit_profile&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;user_id&#34;</span>: <span style="color:#ae81ff">13</span>,
</span></span><span style="display:flex;"><span>		<span style="color:#e6db74">&#34;package&#34;</span> : <span style="color:#e6db74">&#34;main&#34;</span>,
</span></span><span style="display:flex;"><span>  }).<span style="color:#a6e22e">Fatal</span>(<span style="color:#e6db74">&#34;This is a critical message.&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>Here I have specified the log file /tmp/go_logs/example.log.  You can specify according to your need. We also specified the log format <code>JSON</code>.</p>
<h4 id="3-lets-run-the-loggo">3. Lets run the <code>log.go</code></h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ go run log.go
</span></span></code></pre></div><h4 id="4-check-log-file">4. Check log file:</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ cat /tmp/go_logs/example.log
</span></span></code></pre></div><p>Output</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{<span style="color:#f92672">&#34;event&#34;</span>:<span style="color:#e6db74">&#34;create_profile&#34;</span>,<span style="color:#f92672">&#34;level&#34;</span>:<span style="color:#e6db74">&#34;info&#34;</span>,<span style="color:#f92672">&#34;msg&#34;</span>:<span style="color:#e6db74">&#34;This is an info message.&#34;</span>,<span style="color:#f92672">&#34;time&#34;</span>:<span style="color:#e6db74">&#34;2020-06-06T22:51:30+05:30&#34;</span>,<span style="color:#f92672">&#34;user_id&#34;</span>:<span style="color:#ae81ff">10</span>}
</span></span><span style="display:flex;"><span>{<span style="color:#f92672">&#34;event&#34;</span>:<span style="color:#e6db74">&#34;delete_profile&#34;</span>,<span style="color:#f92672">&#34;level&#34;</span>:<span style="color:#e6db74">&#34;warning&#34;</span>,<span style="color:#f92672">&#34;msg&#34;</span>:<span style="color:#e6db74">&#34;This is a warning message.&#34;</span>,<span style="color:#f92672">&#34;time&#34;</span>:<span style="color:#e6db74">&#34;2020-06-06T22:51:30+05:30&#34;</span>,<span style="color:#f92672">&#34;user_id&#34;</span>:<span style="color:#ae81ff">11</span>}
</span></span><span style="display:flex;"><span>{<span style="color:#f92672">&#34;event&#34;</span>:<span style="color:#e6db74">&#34;edit_profile&#34;</span>,<span style="color:#f92672">&#34;level&#34;</span>:<span style="color:#e6db74">&#34;fatal&#34;</span>,<span style="color:#f92672">&#34;msg&#34;</span>:<span style="color:#e6db74">&#34;This is a critical message.&#34;</span>,<span style="color:#f92672">&#34;package&#34;</span>:<span style="color:#e6db74">&#34;main&#34;</span>,<span style="color:#f92672">&#34;time&#34;</span>:<span style="color:#e6db74">&#34;2020-06-06T22:51:30+05:30&#34;</span>,<span style="color:#f92672">&#34;user_id&#34;</span>:<span style="color:#ae81ff">13</span>}
</span></span></code></pre></div><p>Here I have used the log format <code>JSON</code>. Every log will be written in JSON format on the newline. You can check more features about logrus <a href="https://github.com/sirupsen/logrus">here</a>.</p>
<h2 id="2-shift-all-json-logs-on-elasticsearch">2. Shift All JSON logs on Elasticsearch</h2>
<p>This part has no dependency on the above part. You can use any <code>JSON</code> log file irrespective of any language.</p>
<p>Before start I am assuming you have installed Elasticsearch, Filebeat &amp; Kibana on your machine. If not then refer below link:</p>
<ul>
<li><a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html">Install Elasticsearch</a></li>
<li><a href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-installation.html">Install Filebeat</a></li>
<li><a href="https://www.elastic.co/guide/en/kibana/current/install.html">Install Kibana</a></li>
</ul>
<blockquote>
<p><strong>Note: In this part we are not going to use Logstash.</strong></p>
</blockquote>
<h3 id="1-start-elasticsearch-service">1. Start Elasticsearch Service</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ service elasticsearch start
</span></span></code></pre></div><p>It will run on port 9200. You can verify with the below command or just hit <code>localhost:9200</code> on your browser.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>ashish@ashish-laptop:~$ curl localhost:9200
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;name&#34;</span> : <span style="color:#e6db74">&#34;753853fa62d1&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;cluster_name&#34;</span> : <span style="color:#e6db74">&#34;docker-cluster&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;cluster_uuid&#34;</span> : <span style="color:#e6db74">&#34;JLlH0Z0pQqWjGEHO8MQgZQ&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;version&#34;</span> : <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;number&#34;</span> : <span style="color:#e6db74">&#34;7.7.1&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;build_flavor&#34;</span> : <span style="color:#e6db74">&#34;default&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;build_type&#34;</span> : <span style="color:#e6db74">&#34;docker&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;build_hash&#34;</span> : <span style="color:#e6db74">&#34;ad56dce891c901a492bb1ee393f12dfff473a423&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;build_date&#34;</span> : <span style="color:#e6db74">&#34;2020-05-28T16:30:01.040088Z&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;build_snapshot&#34;</span> : false,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;lucene_version&#34;</span> : <span style="color:#e6db74">&#34;8.5.1&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;minimum_wire_compatibility_version&#34;</span> : <span style="color:#e6db74">&#34;6.8.0&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;minimum_index_compatibility_version&#34;</span> : <span style="color:#e6db74">&#34;6.0.0-beta1&#34;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;tagline&#34;</span> : <span style="color:#e6db74">&#34;You Know, for Search&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><h3 id="2-start-kibana-service">2. Start Kibana service</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ service kibana start
</span></span></code></pre></div><p>It will run on port 5601. You can verify by visiting <code>localhost:5601</code> from your browser. You should see the kibana dashboard.</p>
<h3 id="3-edit-filebeatyml">3. Edit <code>filebeat.yml</code></h3>
<p>Open <code>filebeat.yml</code>. Add below snippet in <code>filebeat.inputs</code>:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-yaml" data-lang="yaml"><span style="display:flex;"><span><span style="color:#f92672">filebeat.inputs</span>:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>- <span style="color:#f92672">type</span>: <span style="color:#ae81ff">log</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">enabled</span>: <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">paths</span>:
</span></span><span style="display:flex;"><span>    - <span style="color:#ae81ff">/tmp/go_logs/*.log</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">json.add_error_key</span>: <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">output.elasticsearch</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># Array of hosts to connect to.</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">hosts</span>: [<span style="color:#e6db74">&#34;localhost:9200&#34;</span>]
</span></span></code></pre></div><p>You can check on below link to know more about filebeat log input &amp; JSON decoding</p>
<p><a href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-log.html">https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-log.html</a></p>
<p><a href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-log.html#filebeat-input-log-config-json">https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-log.html#filebeat-input-log-config-json</a></p>
<h3 id="4-restart-filebeat">4. Restart Filebeat</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ service filebeat restart
</span></span></code></pre></div><h2 id="verify-if-data-indexed-on-elasticsearch">Verify If Data Indexed on Elasticsearch</h2>
<h3 id="check-logs">Check Logs</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ tail -f /var/log/filebeat/filebeat
</span></span></code></pre></div><h3 id="check-indices">Check Indices:</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ curl localhost:9200/_cat/indices?v
</span></span></code></pre></div><p>Or you can simply visit <code>localhost:9200/_cat/indices?v</code> on your browser.</p>
<p>Output:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>health status index                            uuid                   pri rep docs.count docs.deleted store.size pri.store.size
</span></span><span style="display:flex;"><span>green  open   .apm-custom-link                 xp0mitnBQtijaZ9tEgan_g   <span style="color:#ae81ff">1</span>   <span style="color:#ae81ff">0</span>          <span style="color:#ae81ff">0</span>            <span style="color:#ae81ff">0</span>       208b           208b
</span></span><span style="display:flex;"><span>green  open   .kibana_task_manager_1           7Q4mMTYxRhCB6sfnQ2ibmA   <span style="color:#ae81ff">1</span>   <span style="color:#ae81ff">0</span>          <span style="color:#ae81ff">5</span>            <span style="color:#ae81ff">0</span>       34kb           34kb
</span></span><span style="display:flex;"><span>green  open   .apm-agent-configuration         3piA79spTbGWAVItYL3PlQ   <span style="color:#ae81ff">1</span>   <span style="color:#ae81ff">0</span>          <span style="color:#ae81ff">0</span>            <span style="color:#ae81ff">0</span>       208b           208b
</span></span><span style="display:flex;"><span>yellow open   filebeat-7.7.1-2020.06.06-000001 nsFk7mOuTguIfaPSbeM3PA   <span style="color:#ae81ff">1</span>   <span style="color:#ae81ff">1</span>         <span style="color:#ae81ff">19</span>            <span style="color:#ae81ff">0</span>     74.9kb         74.9kb
</span></span><span style="display:flex;"><span>green  open   .kibana_1                        LBmzoJspR8a8HAcs9WGr8g   <span style="color:#ae81ff">1</span>   <span style="color:#ae81ff">0</span>         <span style="color:#ae81ff">54</span>            <span style="color:#ae81ff">0</span>    171.6kb        171.6kb
</span></span></code></pre></div><p>As you can see a new index is created by filebeat with the name <code>filebeat-7.7.1-2020.06.06-000001</code>. In your case index name can be different but it will start with <code>filebeat*</code>.</p>
<p>Index lifecycle will be handled by filebeat. You don’t need to worry about that.</p>
<h3 id="check-documents">Check Documents</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ curl localhost:9200/filebeat-7.7.1-2020.06.06-000001/_search?pretty
</span></span></code></pre></div><p>Sample Output:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;_index&#34;</span> : <span style="color:#e6db74">&#34;filebeat-7.7.1-2020.06.06-000001&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;_type&#34;</span> : <span style="color:#e6db74">&#34;_doc&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;_id&#34;</span> : <span style="color:#e6db74">&#34;4qW3inIBVJJF9hMQm_yi&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;_score&#34;</span> : <span style="color:#ae81ff">1.0</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;_source&#34;</span> : {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;@timestamp&#34;</span> : <span style="color:#e6db74">&#34;2020-06-06T17:39:47.208Z&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;log&#34;</span> : {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;offset&#34;</span> : <span style="color:#ae81ff">0</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;file&#34;</span> : {
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;path&#34;</span> : <span style="color:#e6db74">&#34;/tmp/go_logs/ashish.log&#34;</span>
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>    },
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;json&#34;</span> : {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;msg&#34;</span> : <span style="color:#e6db74">&#34;This is an info message.&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;time&#34;</span> : <span style="color:#e6db74">&#34;2020-06-06T23:09:26+05:30&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;user_id&#34;</span> : <span style="color:#ae81ff">10</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;event&#34;</span> : <span style="color:#e6db74">&#34;create_profile&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;level&#34;</span> : <span style="color:#e6db74">&#34;info&#34;</span>
</span></span><span style="display:flex;"><span>    },
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;input&#34;</span> : {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;type&#34;</span> : <span style="color:#e6db74">&#34;log&#34;</span>
</span></span><span style="display:flex;"><span>    },
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;host&#34;</span> : {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;name&#34;</span> : <span style="color:#e6db74">&#34;ashish-laptop&#34;</span>
</span></span><span style="display:flex;"><span>    },
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;agent&#34;</span> : {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;version&#34;</span> : <span style="color:#e6db74">&#34;7.7.1&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;type&#34;</span> : <span style="color:#e6db74">&#34;filebeat&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;ephemeral_id&#34;</span> : <span style="color:#e6db74">&#34;3f53f9c1-66a0-4e93-85fa-1532221c9670&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;hostname&#34;</span> : <span style="color:#e6db74">&#34;ashish-laptop&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;id&#34;</span> : <span style="color:#e6db74">&#34;72976284-d927-49d1-abcb-1d2a5be15176&#34;</span>
</span></span><span style="display:flex;"><span>    },
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;ecs&#34;</span> : {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;version&#34;</span> : <span style="color:#e6db74">&#34;1.5.0&#34;</span>
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>Your data will be saved on the <code>json</code> key. Another is metadata which is added by filebeat. Filebeat provides lots of options, features &amp; settings. You can use it according to your requirements.</p>
<h3 id="logs-on-kibana">Logs on Kibana</h3>
<p>Visit on <code>localhost:5601</code> from your browser. Create index pattern with the pattern <code>filebeat*</code>. Check <a href="https://www.elastic.co/guide/en/kibana/current/tutorial-define-index.html">here</a> for more details.</p>
<p>Once you are done with defining the index pattern, Go to <code>Discover</code> section, Here you will see all your logs.</p>
<p><img loading="lazy" src="/img/go-elk-logs/kibana.png" alt="Kibana-discover"  />
</p>
<p>You can query on your logs. You can apply filters &amp; create various types of dashboard to get better insights from your logs. You can find a wonderful explanation on the official site.</p>
<h2 id="in-the-end">In the end</h2>
<p>We have successfully shipped our logs on Elasticsearch. This is only a small use case of ELKB Stack. It provides much more than this. You can explore more on the internet.</p>
<p>Put your comments if you have any doubts.</p>
]]></content:encoded>
    </item>
    <item>
      <title>Slides</title>
      <link>https://ashish.one/slides/</link>
      <pubDate>Tue, 19 May 2020 17:27:32 +0530</pubDate>
      <guid>https://ashish.one/slides/</guid>
      <description>&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://slides.ashish.one/otel&#34;&gt;Opentelemetry with Elastic&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://slides.ashish.one/function-calling&#34;&gt;Function calling&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
      <content:encoded><![CDATA[<ul>
<li><a href="https://slides.ashish.one/otel">Opentelemetry with Elastic</a></li>
<li><a href="https://slides.ashish.one/function-calling">Function calling</a></li>
</ul>
]]></content:encoded>
    </item>
    <item>
      <title>[Part 1] Setup LEMP environment with Docker - Setup Nginx and PHP</title>
      <link>https://ashish.one/blogs/part-1-setup-lemp-environment-with-docker-setup-nginx-and-php/</link>
      <pubDate>Sat, 16 May 2020 17:01:47 +0530</pubDate>
      <guid>https://ashish.one/blogs/part-1-setup-lemp-environment-with-docker-setup-nginx-and-php/</guid>
      <description>&lt;p&gt;Hi guys, In this series, we are going to setup LEMP Stack (Linux, Nginx, MySQL, PHP). Mainly it is used by web developers. I am assuming you have a basic idea about Docker &amp;amp; How it works.&lt;/p&gt;
&lt;p&gt;In this blog, We are going to setup PHP and Nginx.&lt;/p&gt;
&lt;h3 id=&#34;why-docker&#34;&gt;Why Docker?&lt;/h3&gt;
&lt;p&gt;I will not go too much deep, You can find more resources over the internet about the docker.&lt;/p&gt;
&lt;p&gt;Docker makes the installation process very smooth and it gives your isolated environment as the container.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Hi guys, In this series, we are going to setup LEMP Stack (Linux, Nginx, MySQL, PHP). Mainly it is used by web developers. I am assuming you have a basic idea about Docker &amp; How it works.</p>
<p>In this blog, We are going to setup PHP and Nginx.</p>
<h3 id="why-docker">Why Docker?</h3>
<p>I will not go too much deep, You can find more resources over the internet about the docker.</p>
<p>Docker makes the installation process very smooth and it gives your isolated environment as the container.</p>
<p>With the docker, There will be no more excuses like:</p>
<blockquote>
<p><strong>”It&rsquo;s working on my machine.”  :D</strong></p>
</blockquote>
<p>Because your docker environment remains the same across the platforms, So above excuses will going to turn with:</p>
<blockquote>
<p><strong>”It&rsquo;s working on every machine” ;)</strong></p>
</blockquote>
<p>In Short, Docker makes tech person&rsquo;s life easy like the developer, tester, etc.</p>
<h3 id="my-machine-configuration">My Machine configuration:</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>Docker Version: 18.09.7
</span></span><span style="display:flex;"><span>Docker Compose Version: 1.24.1
</span></span><span style="display:flex;"><span>RAM: 8GB
</span></span><span style="display:flex;"><span>OS: Ubuntu 18.04
</span></span></code></pre></div><p>Make sure docker and docker-compose is installed on your machine.</p>
<h3 id="step-1-create-folders">Step 1: Create folders:</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>mkdir LEMP
</span></span><span style="display:flex;"><span>cd LEMP
</span></span><span style="display:flex;"><span>mkdir <span style="color:#f92672">{</span>public_html,nginx_conf<span style="color:#f92672">}</span>
</span></span></code></pre></div><p><code>public_html</code>: It will contains your PHP code.<br>
<code>nginx_conf</code>: It will contains your Nginx configuration file.</p>
<h3 id="step-2-create-nginx-conf-file">Step 2: Create Nginx conf file</h3>
<p>Go to <code>nginx_conf</code>:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cd nginx_conf
</span></span></code></pre></div><p>Create file <code>lemp-docker.conf</code> (You can give any name according to your requirement) &amp; Paste below configuration block.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>server <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>		listen 80;
</span></span><span style="display:flex;"><span>		server_name _;
</span></span><span style="display:flex;"><span>		root /public_html;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>		location / <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>				index index.php index.html;
</span></span><span style="display:flex;"><span>		<span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>		location ~* <span style="color:#ae81ff">\.</span>php$ <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>				fastcgi_pass    php:9000;
</span></span><span style="display:flex;"><span>				fastcgi_index   index.php;
</span></span><span style="display:flex;"><span>				include         fastcgi_params;
</span></span><span style="display:flex;"><span>				fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
</span></span><span style="display:flex;"><span>				fastcgi_param PATH_INFO $fastcgi_path_info;
</span></span><span style="display:flex;"><span>		<span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>Save and Exit from folder.</p>
<h3 id="step-3-create-file-docker-composeyml">Step 3: Create file <code>docker-compose.yml</code></h3>
<p>Create file <code>docker-compose.yml</code> in <code>LEMP</code> folder &amp; paste the below lines:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>version: <span style="color:#e6db74">&#39;3&#39;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>services:
</span></span><span style="display:flex;"><span> web:
</span></span><span style="display:flex;"><span>  image: nginx
</span></span><span style="display:flex;"><span>  ports:
</span></span><span style="display:flex;"><span>   - <span style="color:#e6db74">&#34;80:80&#34;</span> 
</span></span><span style="display:flex;"><span>  volumes:
</span></span><span style="display:flex;"><span>   - ./public_html:/public_html
</span></span><span style="display:flex;"><span>   - ./nginx_conf:/etc/nginx/conf.d
</span></span><span style="display:flex;"><span>   - /tmp/nginx_logs:/var/log/nginx 
</span></span><span style="display:flex;"><span>  networks:
</span></span><span style="display:flex;"><span>   - nginx-php
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span> php:
</span></span><span style="display:flex;"><span>  image: php:7.2-fpm
</span></span><span style="display:flex;"><span>  volumes:
</span></span><span style="display:flex;"><span>  - ./public_html:/public_html
</span></span><span style="display:flex;"><span>  networks:
</span></span><span style="display:flex;"><span>  - nginx-php
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>networks:
</span></span><span style="display:flex;"><span> nginx-php:
</span></span></code></pre></div><p>Here we have created the network with the name <code>nginx-php</code>. You can check more about the networks <a href="https://docs.docker.com/compose/networking/#specify-custom-networks">here</a>.</p>
<p>You can set <code>volumes</code> path according to your requirement.</p>
<h3 id="step-4-lets-up-the-containers">Step 4: Let&rsquo;s Up the containers</h3>
<p>Create container:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cd LEMP/
</span></span><span style="display:flex;"><span>docker-compose up
</span></span></code></pre></div><p><strong>Note:</strong> Make sure no other service is running on port 80.</p>
<p>Output:</p>
<p><img loading="lazy" src="/img/lemp-docker/docker-compose-up.png" alt="docker compose up"  />
</p>
<p>You can hit the <code>localhost</code> on your browser.</p>
<p>Once you hit the <code>localhost</code> check nginx logs:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cat /tmp/nginx_logs/access.log 
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>172.25.0.1 - - <span style="color:#f92672">[</span>16/May/2020:12:51:04 +0000<span style="color:#f92672">]</span> <span style="color:#e6db74">&#34;GET / HTTP/1.1&#34;</span> <span style="color:#ae81ff">404</span> <span style="color:#ae81ff">556</span> <span style="color:#e6db74">&#34;-&#34;</span> <span style="color:#e6db74">&#34;Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36&#34;</span> <span style="color:#e6db74">&#34;-&#34;</span>
</span></span></code></pre></div><p>Now stop the containers by simply hitting <code>Ctrl + c</code>. Now run docker-compose in detached mode. It will run in the background.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>docker-compose up -d
</span></span></code></pre></div><p>Lists containers</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>docker-compose ps
</span></span></code></pre></div><h3 id="step-5-lets-create-testphp">Step 5: Let&rsquo;s Create <code>test.php</code></h3>
<p>Go to <code>LEMP/public_html</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cd LEMP/public_html
</span></span></code></pre></div><p>Create file <code>test.php</code> &amp; paste below code:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-php" data-lang="php"><span style="display:flex;"><span><span style="color:#f92672">&lt;?</span><span style="color:#a6e22e">php</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">echo</span> <span style="color:#a6e22e">phpinfo</span>();
</span></span></code></pre></div><h3 id="step-6-run-testphp">Step 6: Run <code>test.php</code></h3>
<p>Visit <a href="http://localhost/test.php">http://localhost/test.php</a>.</p>
<p>Output:</p>
<p><img loading="lazy" src="/img/lemp-docker/phpinfo.png" alt="phpinfo"  />
</p>
<h3 id="at-the-end">At the End</h3>
<p>We have successfully created Nginx and PHP Environment. In Part 2, We will check, How we can add MySQL to this environment.</p>
]]></content:encoded>
    </item>
    <item>
      <title>Add Responsive Google Slides on Hugo</title>
      <link>https://ashish.one/blogs/add-responsive-google-slides-on-hugo/</link>
      <pubDate>Mon, 13 Apr 2020 14:11:53 +0530</pubDate>
      <guid>https://ashish.one/blogs/add-responsive-google-slides-on-hugo/</guid>
      <description>&lt;p&gt;Steps to add Responsive google slides iframe with Hugo:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Hugo version:&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ hugo version
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Hugo Static Site Generator v0.69.0-4205844B linux/amd64 BuildDate: 2020-04-10T09:12:34Z
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;step-1-create-shortcode&#34;&gt;Step 1: Create Shortcode&lt;/h2&gt;
&lt;h3 id=&#34;create-gslideshtml-file&#34;&gt;Create &lt;code&gt;gslides.html&lt;/code&gt; file&lt;/h3&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;vim layouts/shortcodes/gslides.html
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;step-2-add-below-code&#34;&gt;Step 2: Add below code:&lt;/h2&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Container&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;padding-bottom:56.25%; position:relative; display:block; width: 100%&amp;#34;&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt; &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;iframe&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;id&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;googleSlideIframe&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#a6e22e&#34;&gt;width&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;100%&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;height&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;100%&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#a6e22e&#34;&gt;src&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;{{ .Get &amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;src&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;}}&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#a6e22e&#34;&gt;frameborder&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;0&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;allowfullscreen&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;position:absolute; top:0; left: 0&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;iframe&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;step-3-use-shortcode-gslides-in-your-blogpost-markdown-file&#34;&gt;Step 3: Use shortcode &amp;lsquo;gslides&amp;rsquo; in your Blog/Post Markdown file&lt;/h2&gt;
&lt;p&gt;Simply place below snippet in your markdown file.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Steps to add Responsive google slides iframe with Hugo:</p>
<p><strong>Hugo version:</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ hugo version
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Hugo Static Site Generator v0.69.0-4205844B linux/amd64 BuildDate: 2020-04-10T09:12:34Z
</span></span></code></pre></div><h2 id="step-1-create-shortcode">Step 1: Create Shortcode</h2>
<h3 id="create-gslideshtml-file">Create <code>gslides.html</code> file</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>vim layouts/shortcodes/gslides.html
</span></span></code></pre></div><h2 id="step-2-add-below-code">Step 2: Add below code:</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>&lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;Container&#34;</span>
</span></span><span style="display:flex;"><span> <span style="color:#a6e22e">style</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;padding-bottom:56.25%; position:relative; display:block; width: 100%&#34;</span>&gt;
</span></span><span style="display:flex;"><span> &lt;<span style="color:#f92672">iframe</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;googleSlideIframe&#34;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">width</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;100%&#34;</span> <span style="color:#a6e22e">height</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;100%&#34;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;{{ .Get &#34;</span><span style="color:#a6e22e">src</span><span style="color:#960050;background-color:#1e0010">&#34;</span> <span style="color:#960050;background-color:#1e0010">}}&#34;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">frameborder</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;0&#34;</span> <span style="color:#a6e22e">allowfullscreen</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;&#34;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">style</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;position:absolute; top:0; left: 0&#34;</span>&gt;&lt;/<span style="color:#f92672">iframe</span>&gt;
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">div</span>&gt;
</span></span></code></pre></div><h2 id="step-3-use-shortcode-gslides-in-your-blogpost-markdown-file">Step 3: Use shortcode &lsquo;gslides&rsquo; in your Blog/Post Markdown file</h2>
<p>Simply place below snippet in your markdown file.</p>
<p>Replace <code>src</code> value with your Google slide URL.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span><code>{</code>{<code>&lt; gslides src="https://docs.google.com/presentation/d/e/2PACX-1vQExSl-gRPoA9hC6qXuqrjwiQVHAanDieZN_5GpV2Lw9cuxjsVFEN_wkTThqpQwZ36vJz4zwmTvV7cC/embed?start=false&loop=false&delayms=3000" ></code><code>}}</code>

</span></span></code></pre></div><blockquote>
<p><strong>I have shown for google slides, Similarly, you can create or add any other document type like google sheets, doc, etc. OR you can place any iframe like this.</strong></p>
</blockquote>
]]></content:encoded>
    </item>
    <item>
      <title>Challenges in linuxfromscratch</title>
      <link>https://ashish.one/blogs/challenges-in-linuxfromscratch/</link>
      <pubDate>Sat, 11 Apr 2020 13:55:52 +0530</pubDate>
      <guid>https://ashish.one/blogs/challenges-in-linuxfromscratch/</guid>
      <description>&lt;p&gt;&lt;img loading=&#34;lazy&#34; src=&#34;https://pbs.twimg.com/media/EWmoua6UYAAjwgC?format=jpg&amp;amp;name=large&#34; alt=&#34;lfs_screen&#34;  /&gt;
&lt;/p&gt;
&lt;blockquote class=&#34;twitter-tweet&#34;&gt;&lt;p lang=&#34;en&#34; dir=&#34;ltr&#34;&gt;Successfully built custom &lt;a href=&#34;https://twitter.com/hashtag/Linux?src=hash&amp;amp;ref_src=twsrc%5Etfw&#34;&gt;#Linux&lt;/a&gt; system by referring &lt;a href=&#34;https://t.co/lyrdKkfXo9&#34;&gt;https://t.co/lyrdKkfXo9&lt;/a&gt; .&lt;br&gt;&lt;br&gt;Listed my challenges here &lt;a href=&#34;https://t.co/gU2SoAxly2&#34;&gt;https://t.co/gU2SoAxly2&lt;/a&gt;&lt;a href=&#34;https://twitter.com/nixcraft?ref_src=twsrc%5Etfw&#34;&gt;@nixcraft&lt;/a&gt;&lt;a href=&#34;https://twitter.com/hashtag/linux?src=hash&amp;amp;ref_src=twsrc%5Etfw&#34;&gt;#linux&lt;/a&gt; &lt;a href=&#34;https://twitter.com/hashtag/lfs?src=hash&amp;amp;ref_src=twsrc%5Etfw&#34;&gt;#lfs&lt;/a&gt; &lt;a href=&#34;https://twitter.com/hashtag/linuxfromscratch?src=hash&amp;amp;ref_src=twsrc%5Etfw&#34;&gt;#linuxfromscratch&lt;/a&gt; &lt;a href=&#34;https://t.co/XlWchVHy26&#34;&gt;pic.twitter.com/XlWchVHy26&lt;/a&gt;&lt;/p&gt;&amp;mdash; Ashish Tiwari 🇮🇳 (@_ashish_tiwari) &lt;a href=&#34;https://twitter.com/_ashish_tiwari/status/1254719517491511296?ref_src=twsrc%5Etfw&#34;&gt;April 27, 2020&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async src=&#34;https://platform.twitter.com/widgets.js&#34; charset=&#34;utf-8&#34;&gt;&lt;/script&gt;


&lt;p&gt;I have started with &lt;a href=&#34;https://www.linuxfromscratch.org&#34;&gt;www.linuxfromscratch.org&lt;/a&gt;, I am facing some challenges and problems which I am going to share with you in this blog. I will keep updating this blog as well as I move forward.&lt;/p&gt;
&lt;h2 id=&#34;before-we-get-start&#34;&gt;Before we get start&lt;/h2&gt;
&lt;p&gt;You need some basic linux command knowledge to use linuxfromscratch guide. I am going to build LFS on my local machine. If your machine has a different OS or different configuration, Then some solution will not work.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p><img loading="lazy" src="https://pbs.twimg.com/media/EWmoua6UYAAjwgC?format=jpg&amp;name=large" alt="lfs_screen"  />
</p>
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Successfully built custom <a href="https://twitter.com/hashtag/Linux?src=hash&amp;ref_src=twsrc%5Etfw">#Linux</a> system by referring <a href="https://t.co/lyrdKkfXo9">https://t.co/lyrdKkfXo9</a> .<br><br>Listed my challenges here <a href="https://t.co/gU2SoAxly2">https://t.co/gU2SoAxly2</a><a href="https://twitter.com/nixcraft?ref_src=twsrc%5Etfw">@nixcraft</a><a href="https://twitter.com/hashtag/linux?src=hash&amp;ref_src=twsrc%5Etfw">#linux</a> <a href="https://twitter.com/hashtag/lfs?src=hash&amp;ref_src=twsrc%5Etfw">#lfs</a> <a href="https://twitter.com/hashtag/linuxfromscratch?src=hash&amp;ref_src=twsrc%5Etfw">#linuxfromscratch</a> <a href="https://t.co/XlWchVHy26">pic.twitter.com/XlWchVHy26</a></p>&mdash; Ashish Tiwari 🇮🇳 (@_ashish_tiwari) <a href="https://twitter.com/_ashish_tiwari/status/1254719517491511296?ref_src=twsrc%5Etfw">April 27, 2020</a></blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>


<p>I have started with <a href="https://www.linuxfromscratch.org">www.linuxfromscratch.org</a>, I am facing some challenges and problems which I am going to share with you in this blog. I will keep updating this blog as well as I move forward.</p>
<h2 id="before-we-get-start">Before we get start</h2>
<p>You need some basic linux command knowledge to use linuxfromscratch guide. I am going to build LFS on my local machine. If your machine has a different OS or different configuration, Then some solution will not work.</p>
<p>I am going to use the same chapter title as mentioned in linuxfromscratch. I will skip those sections where I haven&rsquo;t faced any difficulties.</p>
<h2 id="my-machine-configuration">My Machine Configuration</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>OS: Ubuntu 14.04
</span></span><span style="display:flex;"><span>RAM: 2GB
</span></span><span style="display:flex;"><span>Disk: <span style="color:#ae81ff">500</span> GB
</span></span></code></pre></div><h2 id="going-to-build">Going to build</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>LFS version: 9.1
</span></span><span style="display:flex;"><span>Published: March 1st, <span style="color:#ae81ff">2020</span>
</span></span><span style="display:flex;"><span>LFS doc:http://www.linuxfromscratch.org/lfs/downloads/9.1/LFS-BOOK-9.1-NOCHUNKS.html
</span></span></code></pre></div><h2 id="challenges">Challenges</h2>
<h2 id="22-host-system-requirements">2.2. Host System Requirements</h2>
<p>Doc link: <a href="http://www.linuxfromscratch.org/lfs/downloads/9.1/LFS-BOOK-9.1-NOCHUNKS.html#ch-partitioning-hostreqs">http://www.linuxfromscratch.org/lfs/downloads/9.1/LFS-BOOK-9.1-NOCHUNKS.html#ch-partitioning-hostreqs</a></p>
<h3 id="version-check">Version check</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cat &gt; version-check.sh &lt;&lt; <span style="color:#e6db74">&#34;EOF&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">#!/bin/bash</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Simple script to list version numbers of critical development tools</span>
</span></span><span style="display:flex;"><span>export LC_ALL<span style="color:#f92672">=</span>C
</span></span><span style="display:flex;"><span>bash --version | head -n1 | cut -d<span style="color:#e6db74">&#34; &#34;</span> -f2-4
</span></span><span style="display:flex;"><span>MYSH<span style="color:#f92672">=</span><span style="color:#66d9ef">$(</span>readlink -f /bin/sh<span style="color:#66d9ef">)</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#34;/bin/sh -&gt; </span>$MYSH<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>echo $MYSH | grep -q bash <span style="color:#f92672">||</span> echo <span style="color:#e6db74">&#34;ERROR: /bin/sh does not point to bash&#34;</span>
</span></span><span style="display:flex;"><span>unset MYSH
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo -n <span style="color:#e6db74">&#34;Binutils: &#34;</span>; ld --version | head -n1 | cut -d<span style="color:#e6db74">&#34; &#34;</span> -f3-
</span></span><span style="display:flex;"><span>bison --version | head -n1
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> <span style="color:#f92672">[</span> -h /usr/bin/yacc <span style="color:#f92672">]</span>; <span style="color:#66d9ef">then</span>
</span></span><span style="display:flex;"><span>  echo <span style="color:#e6db74">&#34;/usr/bin/yacc -&gt; `readlink -f /usr/bin/yacc`&#34;</span>;
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">elif</span> <span style="color:#f92672">[</span> -x /usr/bin/yacc <span style="color:#f92672">]</span>; <span style="color:#66d9ef">then</span>
</span></span><span style="display:flex;"><span>  echo yacc is <span style="color:#e6db74">`</span>/usr/bin/yacc --version | head -n1<span style="color:#e6db74">`</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">else</span>
</span></span><span style="display:flex;"><span>  echo <span style="color:#e6db74">&#34;yacc not found&#34;</span> 
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">fi</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>bzip2 --version 2&gt;&amp;<span style="color:#ae81ff">1</span> &lt; /dev/null | head -n1 | cut -d<span style="color:#e6db74">&#34; &#34;</span> -f1,6-
</span></span><span style="display:flex;"><span>echo -n <span style="color:#e6db74">&#34;Coreutils: &#34;</span>; chown --version | head -n1 | cut -d<span style="color:#e6db74">&#34;)&#34;</span> -f2
</span></span><span style="display:flex;"><span>diff --version | head -n1
</span></span><span style="display:flex;"><span>find --version | head -n1
</span></span><span style="display:flex;"><span>gawk --version | head -n1
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> <span style="color:#f92672">[</span> -h /usr/bin/awk <span style="color:#f92672">]</span>; <span style="color:#66d9ef">then</span>
</span></span><span style="display:flex;"><span>  echo <span style="color:#e6db74">&#34;/usr/bin/awk -&gt; `readlink -f /usr/bin/awk`&#34;</span>;
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">elif</span> <span style="color:#f92672">[</span> -x /usr/bin/awk <span style="color:#f92672">]</span>; <span style="color:#66d9ef">then</span>
</span></span><span style="display:flex;"><span>  echo awk is <span style="color:#e6db74">`</span>/usr/bin/awk --version | head -n1<span style="color:#e6db74">`</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">else</span> 
</span></span><span style="display:flex;"><span>  echo <span style="color:#e6db74">&#34;awk not found&#34;</span> 
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">fi</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>gcc --version | head -n1
</span></span><span style="display:flex;"><span>g++ --version | head -n1
</span></span><span style="display:flex;"><span>ldd --version | head -n1 | cut -d<span style="color:#e6db74">&#34; &#34;</span> -f2-  <span style="color:#75715e"># glibc version</span>
</span></span><span style="display:flex;"><span>grep --version | head -n1
</span></span><span style="display:flex;"><span>gzip --version | head -n1
</span></span><span style="display:flex;"><span>cat /proc/version
</span></span><span style="display:flex;"><span>m4 --version | head -n1
</span></span><span style="display:flex;"><span>make --version | head -n1
</span></span><span style="display:flex;"><span>patch --version | head -n1
</span></span><span style="display:flex;"><span>echo Perl <span style="color:#e6db74">`</span>perl -V:version<span style="color:#e6db74">`</span>
</span></span><span style="display:flex;"><span>python3 --version
</span></span><span style="display:flex;"><span>sed --version | head -n1
</span></span><span style="display:flex;"><span>tar --version | head -n1
</span></span><span style="display:flex;"><span>makeinfo --version | head -n1  <span style="color:#75715e"># texinfo version</span>
</span></span><span style="display:flex;"><span>xz --version | head -n1
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#39;int main(){}&#39;</span> &gt; dummy.c <span style="color:#f92672">&amp;&amp;</span> g++ -o dummy dummy.c
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> <span style="color:#f92672">[</span> -x dummy <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">then</span> echo <span style="color:#e6db74">&#34;g++ compilation OK&#34;</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">else</span> echo <span style="color:#e6db74">&#34;g++ compilation failed&#34;</span>; <span style="color:#66d9ef">fi</span>
</span></span><span style="display:flex;"><span>rm -f dummy.c dummy
</span></span><span style="display:flex;"><span>EOF
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>bash version-check.sh
</span></span></code></pre></div><h3 id="error-1">Error 1:</h3>
<p><code>/bin/sh does not point to bash</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>sudo ln -sf bash /bin/sh
</span></span></code></pre></div><h3 id="error-2">Error 2:</h3>
<p><code>version-check.sh: line 11: bison: command not found</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>sudo apt-get install bison
</span></span></code></pre></div><h3 id="error-3">Error 3:</h3>
<p><code>version-check.sh: line 25: gawk: command not found</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>sudo apt-get install gawk
</span></span></code></pre></div><h3 id="error-4">Error 4:</h3>
<p><code>version-check.sh: line 36: g++: command not found</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>sudo apt-get install g++
</span></span></code></pre></div><h3 id="error-5">Error 5:</h3>
<p><code>version-check.sh: line 48: makeinfo: command not found</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>sudo apt-get update -y
</span></span><span style="display:flex;"><span>sudo apt-get install -y texinfo
</span></span></code></pre></div><h3 id="final-success-output">Final success output:</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ bash version-check.sh
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>bash, version 4.3.11<span style="color:#f92672">(</span>1<span style="color:#f92672">)</span>-release
</span></span><span style="display:flex;"><span>/bin/sh -&gt; /bin/bash
</span></span><span style="display:flex;"><span>Binutils: <span style="color:#f92672">(</span>GNU Binutils <span style="color:#66d9ef">for</span> Ubuntu<span style="color:#f92672">)</span> 2.24
</span></span><span style="display:flex;"><span>bison <span style="color:#f92672">(</span>GNU Bison<span style="color:#f92672">)</span> 3.0.2
</span></span><span style="display:flex;"><span>/usr/bin/yacc -&gt; /usr/bin/bison.yacc
</span></span><span style="display:flex;"><span>bzip2,  Version 1.0.6, 6-Sept-2010.
</span></span><span style="display:flex;"><span>Coreutils:  8.21
</span></span><span style="display:flex;"><span>diff <span style="color:#f92672">(</span>GNU diffutils<span style="color:#f92672">)</span> 3.3
</span></span><span style="display:flex;"><span>find <span style="color:#f92672">(</span>GNU findutils<span style="color:#f92672">)</span> 4.4.2
</span></span><span style="display:flex;"><span>GNU Awk 4.0.1
</span></span><span style="display:flex;"><span>/usr/bin/awk -&gt; /usr/bin/gawk
</span></span><span style="display:flex;"><span>gcc <span style="color:#f92672">(</span>Ubuntu 4.8.4-2ubuntu1~14.04.4<span style="color:#f92672">)</span> 4.8.4
</span></span><span style="display:flex;"><span>g++ <span style="color:#f92672">(</span>Ubuntu 4.8.4-2ubuntu1~14.04.4<span style="color:#f92672">)</span> 4.8.4
</span></span><span style="display:flex;"><span><span style="color:#f92672">(</span>Ubuntu EGLIBC 2.19-0ubuntu6.15<span style="color:#f92672">)</span> 2.19
</span></span><span style="display:flex;"><span>grep <span style="color:#f92672">(</span>GNU grep<span style="color:#f92672">)</span> 2.16
</span></span><span style="display:flex;"><span>gzip 1.6
</span></span><span style="display:flex;"><span>Linux version 4.4.0-142-generic <span style="color:#f92672">(</span>buildd@lcy01-amd64-006<span style="color:#f92672">)</span> <span style="color:#f92672">(</span>gcc version 4.8.4 <span style="color:#f92672">(</span>Ubuntu 4.8.4-2ubuntu1~14.04.4<span style="color:#f92672">)</span> <span style="color:#f92672">)</span> <span style="color:#75715e">#168~14.04.1-Ubuntu SMP Sat Jan 19 11:26:28 UTC 2019</span>
</span></span><span style="display:flex;"><span>m4 <span style="color:#f92672">(</span>GNU M4<span style="color:#f92672">)</span> 1.4.17
</span></span><span style="display:flex;"><span>GNU Make 3.81
</span></span><span style="display:flex;"><span>GNU patch 2.7.1
</span></span><span style="display:flex;"><span>Perl version<span style="color:#f92672">=</span><span style="color:#e6db74">&#39;5.18.2&#39;</span>;
</span></span><span style="display:flex;"><span>Python 3.4.3
</span></span><span style="display:flex;"><span>sed <span style="color:#f92672">(</span>GNU sed<span style="color:#f92672">)</span> 4.2.2
</span></span><span style="display:flex;"><span>tar <span style="color:#f92672">(</span>GNU tar<span style="color:#f92672">)</span> 1.27.1
</span></span><span style="display:flex;"><span>makeinfo <span style="color:#f92672">(</span>GNU texinfo<span style="color:#f92672">)</span> 5.2
</span></span><span style="display:flex;"><span>xz <span style="color:#f92672">(</span>XZ Utils<span style="color:#f92672">)</span> 5.1.0alpha
</span></span><span style="display:flex;"><span>g++ compilation OK
</span></span></code></pre></div><h2 id="25-creating-a-file-system-on-the-partition">2.5. Creating a File System on the Partition</h2>
<p>Doc link: <a href="http://www.linuxfromscratch.org/lfs/downloads/9.1/LFS-BOOK-9.1-NOCHUNKS.html#ch-partitioning-creatingfilesystem">http://www.linuxfromscratch.org/lfs/downloads/9.1/LFS-BOOK-9.1-NOCHUNKS.html#ch-partitioning-creatingfilesystem</a></p>
<p>I had only one partition. I need to create new <strong>physical</strong> partition for LFS.</p>
<blockquote>
<p>It is recommended to use Physical partition only not logical.</p>
</blockquote>
<p>I have reinstall my OS with new partition which is long way. You can use <a href="https://www.howtogeek.com/114503/how-to-resize-your-ubuntu-partitions/">GParted</a> to make partitions. Remember you can create only 4 Physical partition. Give 1 physical partition dedicated to LFS. Below is my partition view.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ lsblk
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
</span></span><span style="display:flex;"><span>sda      8:0    <span style="color:#ae81ff">0</span> 465.8G  <span style="color:#ae81ff">0</span> disk 
</span></span><span style="display:flex;"><span>|-sda1   8:1    <span style="color:#ae81ff">0</span>   476M  <span style="color:#ae81ff">0</span> part /boot/efi
</span></span><span style="display:flex;"><span>|-sda2   8:2    <span style="color:#ae81ff">0</span>   1.9G  <span style="color:#ae81ff">0</span> part <span style="color:#f92672">[</span>SWAP<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>|-sda3   8:3    <span style="color:#ae81ff">0</span> 190.8G  <span style="color:#ae81ff">0</span> part /
</span></span><span style="display:flex;"><span><span style="color:#e6db74">`</span>-sda4   8:4    <span style="color:#ae81ff">0</span> 272.7G  <span style="color:#ae81ff">0</span> part /lfs
</span></span></code></pre></div><h3 id="challenge-my-partition-wipe-out-after-restart-my-system">Challenge: My Partition wipe out after restart my system</h3>
<p>After restart I again hit the same command <code>lsblk</code>. <code>/lfs</code> partition was not there.</p>
<p>In Ubuntu, You need to make entry in <code>/etc/fstab</code> in order to mount the partition on restart.</p>
<p>You have to find first volumeId or UUID to make entry in <code>/etc/fstab</code>. You can use <code>blkid</code> command to get all UUID:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ blkid
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>/dev/sda1: UUID<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;1FBD-F51A&#34;</span> TYPE<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;vfat&#34;</span> 
</span></span><span style="display:flex;"><span>/dev/sda2: UUID<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;9f41c453-3b5c-4537-81b0-2fb33f19ded8&#34;</span> TYPE<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;swap&#34;</span> 
</span></span><span style="display:flex;"><span>/dev/sda3: UUID<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;1a16afba-cabb-40c7-b704-1129b7004ffb&#34;</span> TYPE<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ext4&#34;</span> 
</span></span><span style="display:flex;"><span>/dev/sda4: UUID<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;b3b2eb8c-2a43-405d-97da-af8b46c743e2&#34;</span> TYPE<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ext4&#34;</span> 
</span></span></code></pre></div><p>Above my Partition is <code>/dev/sda4</code> which is mounted on <code>/lfs</code>, So my UUID is <code>b3b2eb8c-2a43-405d-97da-af8b46c743e2</code>. Now I have added below line in <code>/etc/fstab</code>.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>UUID<span style="color:#f92672">=</span>b3b2eb8c-2a43-405d-97da-af8b46c743e2 /lfs            ext4    rw,user,exec,errors<span style="color:#f92672">=</span>remount-ro              <span style="color:#ae81ff">0</span>       <span style="color:#ae81ff">0</span>
</span></span></code></pre></div><p>Here</p>
<ul>
<li><code>rw</code>: Read, Write</li>
<li><code>exec</code>: Execute</li>
<li><code>errors=remount-ro</code>: It will mount as Read-Only, If you get any error on mounting.</li>
</ul>
<blockquote>
<p>Make sure you have added <code>exec</code>, Otherwise you cannot execute any binaries from chapter <a href="http://www.linuxfromscratch.org/lfs/downloads/9.1/LFS-BOOK-9.1-NOCHUNKS.html#ch-tools-binutils-pass1">5.4. Binutils-2.34 - Pass 1</a></p>
</blockquote>
<h2 id="54-binutils-234---pass-1">5.4. Binutils-2.34 - Pass 1</h2>
<p>Doc link: <a href="http://www.linuxfromscratch.org/lfs/downloads/9.1/LFS-BOOK-9.1-NOCHUNKS.html#ch-tools-binutils-pass1">http://www.linuxfromscratch.org/lfs/downloads/9.1/LFS-BOOK-9.1-NOCHUNKS.html#ch-tools-binutils-pass1</a></p>
<h3 id="error-1-1">Error 1:</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>bash: ../configure: No such file or directory
</span></span></code></pre></div><p>As I mentioned on above Section, Make sure you have added <code>exec</code> in your <code>/etc/fstab</code> entry OR Make sure your partition <code>/lfs</code> has Read, Write &amp; Execute permission. Below <code>/etc/fstab</code> entry worked for me:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>UUID<span style="color:#f92672">=</span>b3b2eb8c-2a43-405d-97da-af8b46c743e2 /lfs            ext4    rw,user,exec,errors<span style="color:#f92672">=</span>remount-ro              <span style="color:#ae81ff">0</span>       <span style="color:#ae81ff">0</span>
</span></span></code></pre></div><p>This setting can be different for different OS.</p>
<h3 id="error-2-1">Error 2:</h3>
<p>I had no idea where to create <code>build</code> folder.</p>
<p>Below steps worked for me:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ cd $LFS/source
</span></span><span style="display:flex;"><span>$ tar xvf binutils-2.34.tar.xz
</span></span><span style="display:flex;"><span>$ cd binutils-2.34
</span></span><span style="display:flex;"><span>$ mkdir -v build
</span></span><span style="display:flex;"><span>$ cd build
</span></span><span style="display:flex;"><span>$ ../configure --prefix<span style="color:#f92672">=</span>/tools          <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>             --with-sysroot<span style="color:#f92672">=</span>$LFS        <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>             --with-lib-path<span style="color:#f92672">=</span>/tools/lib <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>             --target<span style="color:#f92672">=</span>$LFS_TGT          <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>             --disable-nls              <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>             --disable-werror
</span></span></code></pre></div><h2 id="55-gcc-920---pass-1">5.5. GCC-9.2.0 - Pass 1</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cd $LFS/sources
</span></span><span style="display:flex;"><span>tar -xvf gcc-9.2.0.tar.xz
</span></span><span style="display:flex;"><span>cd gcc-9.2.0
</span></span></code></pre></div><p>After this you can continue with document flow.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>tar -xf ../mpfr-4.0.2.tar.xz
</span></span><span style="display:flex;"><span>mv -v mpfr-4.0.2 mpfr
</span></span><span style="display:flex;"><span>tar -xf ../gmp-6.2.0.tar.xz
</span></span><span style="display:flex;"><span>mv -v gmp-6.2.0 gmp
</span></span><span style="display:flex;"><span>tar -xf ../mpc-1.1.0.tar.gz
</span></span><span style="display:flex;"><span>mv -v mpc-1.1.0 mpc
</span></span></code></pre></div><h3 id="error-1-2">Error 1:</h3>
<p>On <code>make</code> command, I got below error:</p>
<h4 id="error-for-loop-initial-declarations-are-only-allowed-in-c99-mode">error: &lsquo;for&rsquo; loop initial declarations are only allowed in C99 mode</h4>
<pre tabindex="0"><code>compute_powtab.c: In function &#39;mpn_compute_powtab_mul&#39;:
compute_powtab.c:142:3: error: &#39;for&#39; loop initial declarations are only allowed in C99 mode
   for (long pi = start_idx; pi &gt;= 0; pi--)
   ^
compute_powtab.c:142:3: note: use option -std=c99 or -std=gnu99 to compile your code
compute_powtab.c: In function &#39;mpn_compute_powtab_div&#39;:
compute_powtab.c:226:3: error: &#39;for&#39; loop initial declarations are only allowed in C99 mode
   for (long pi = n_pows - 1; pi &gt;= 0; pi--)
   ^
compute_powtab.c:274:13: error: redefinition of &#39;pi&#39;
   for (long pi = n_pows; pi &gt;= 0; pi--)
             ^
compute_powtab.c:226:13: note: previous definition of &#39;pi&#39; was here
   for (long pi = n_pows - 1; pi &gt;= 0; pi--)
             ^
compute_powtab.c:274:3: error: &#39;for&#39; loop initial declarations are only allowed in C99 mode
   for (long pi = n_pows; pi &gt;= 0; pi--)
   ^
compute_powtab.c: In function &#39;powtab_decide&#39;:
compute_powtab.c:296:3: error: &#39;for&#39; loop initial declarations are only allowed in C99 mode
   for (size_t pn = (un + 1) &gt;&gt; 1; pn != 1; pn = (pn + 1) &gt;&gt; 1)
   ^
compute_powtab.c:304:10: error: redefinition of &#39;pn&#39;
   size_t pn = un - 1;
          ^
compute_powtab.c:296:15: note: previous definition of &#39;pn&#39; was here
   for (size_t pn = (un + 1) &gt;&gt; 1; pn != 1; pn = (pn + 1) &gt;&gt; 1)
               ^
compute_powtab.c:308:3: error: &#39;for&#39; loop initial declarations are only allowed in C99 mode
   for (long i = n_pows - 2; i &gt;= 0; i--)
</code></pre><p>As per (<a href="https://stackoverflow.com/a/29338269)%5Bhttps://stackoverflow.com/a/29338269%5D">https://stackoverflow.com/a/29338269)[https://stackoverflow.com/a/29338269]</a>,</p>
<blockquote>
<p><strong>This happens because declaring variables inside a for loop wasn&rsquo;t valid C until C99(which is the standard of C published in 1999).</strong></p>
</blockquote>
<h4 id="how-i-sovled-this">How I sovled this?</h4>
<p>Open file:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>vim $LFS/sources/gcc-9.2.0/build/gmp/mpn/compute_powtab.c
</span></span></code></pre></div><p><strong>We will solve first error:</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>compute_powtab.c:226:3: error: <span style="color:#e6db74">&#39;for&#39;</span> loop initial declarations are only allowed in C99 mode
</span></span><span style="display:flex;"><span>   <span style="color:#66d9ef">for</span> <span style="color:#f92672">(</span>long pi <span style="color:#f92672">=</span> n_pows - 1; pi &gt;<span style="color:#f92672">=</span> 0; pi--<span style="color:#f92672">)</span>
</span></span></code></pre></div><p>Changes on line number 226:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>  long pi;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">for</span> <span style="color:#f92672">(</span>pi <span style="color:#f92672">=</span> n_pows - 1; pi &gt;<span style="color:#f92672">=</span> 0; pi--<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">{</span>
</span></span></code></pre></div><p>Just declare <code>long pi;</code> outside the loop. Similarly you can solve above all errors.</p>
<p><strong>OR</strong></p>
<p>You can download my edited version of <a href="/download/compute_powtab.c">compute_powtab.c</a>, Place in <code>$LFS/sources/gcc-9.2.0/build/gmp/mpn/</code>.</p>
<p>Hit</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>make
</span></span></code></pre></div><p>Now it should works :)</p>
<h2 id="57-glibc-231">5.7. Glibc-2.31</h2>
<p>On below command:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>../configure                             <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>      --prefix<span style="color:#f92672">=</span>/tools                    <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>      --host<span style="color:#f92672">=</span>$LFS_TGT                    <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>      --build<span style="color:#f92672">=</span><span style="color:#66d9ef">$(</span>../scripts/config.guess<span style="color:#66d9ef">)</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>      --enable-kernel<span style="color:#f92672">=</span>3.2                <span style="color:#ae81ff">\
</span></span></span></code></pre></div><h3 id="error-these-critical-programs-are-missing-or-too-old-make">Error: These critical programs are missing or too old: make</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>configure: error:
</span></span><span style="display:flex;"><span>*** These critical programs are missing or too old: make
</span></span><span style="display:flex;"><span>*** Check the INSTALL file <span style="color:#66d9ef">for</span> required versions.
</span></span></code></pre></div><p>I checked my current <code>make</code> version:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ make --version
</span></span><span style="display:flex;"><span>GNU Make 3.81
</span></span><span style="display:flex;"><span>Copyright <span style="color:#f92672">(</span>C<span style="color:#f92672">)</span> <span style="color:#ae81ff">2006</span>  Free Software Foundation, Inc.
</span></span><span style="display:flex;"><span>This is free software; see the source <span style="color:#66d9ef">for</span> copying conditions.
</span></span><span style="display:flex;"><span>There is NO warranty; not even <span style="color:#66d9ef">for</span> MERCHANTABILITY or FITNESS FOR A
</span></span><span style="display:flex;"><span>PARTICULAR PURPOSE.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>This program built <span style="color:#66d9ef">for</span> x86_64-pc-linux-gnu
</span></span></code></pre></div><p>As per (<a href="https://stackoverflow.com/a/31915313)%5Bhttps://stackoverflow.com/a/31915313%5D">https://stackoverflow.com/a/31915313)[https://stackoverflow.com/a/31915313]</a></p>
<blockquote>
<p><strong>Due to a long-standing unresolved Debian bug report, GNU Make remained the age-old 3.81 in Debian for a very long time, and as a consequence, in Debian-based distributions such as Ubuntu and Mint.</strong></p>
</blockquote>
<p>So we need to upgrade our make version. Below steps worked for me.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cd /tmp
</span></span><span style="display:flex;"><span>wget http://ftp.gnu.org/gnu/make/make-4.1.tar.gz
</span></span><span style="display:flex;"><span>tar xvf make-4.1.tar.gz
</span></span><span style="display:flex;"><span>cd make-4.1/
</span></span><span style="display:flex;"><span>./configure
</span></span><span style="display:flex;"><span>make
</span></span><span style="display:flex;"><span>sudo make install
</span></span><span style="display:flex;"><span>sudo mv /usr/local/bin/make /usr/bin/make
</span></span></code></pre></div><p>Now again hit <code>../configure ..</code> command, Now it should work :)</p>
<h2 id="67-linux-553-api-headers">6.7. Linux-5.5.3 API Headers</h2>
<h3 id="error">Error</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="color:#f92672">(</span>lfs chroot<span style="color:#f92672">)</span> root:/sources/linux-5.5.3# make mrproper
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>/bin/sh: sed: command not found
</span></span><span style="display:flex;"><span>Makefile:653: arch//Makefile: No such file or directory
</span></span><span style="display:flex;"><span>make: *** No rule to make target <span style="color:#e6db74">&#39;arch//Makefile&#39;</span>.  Stop.
</span></span></code></pre></div><p>Because of my silly mistake. I had not installed the sed package. I just reinstall the package.</p>
<h2 id="612-bzip2-108">6.12. Bzip2-1.0.8</h2>
<h3 id="error-6">Error:</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>collect2: error: ld returned <span style="color:#ae81ff">1</span> exit status
</span></span><span style="display:flex;"><span>make: *** <span style="color:#f92672">[</span>Makefile-libbz2_so:38: all<span style="color:#f92672">]</span> Error <span style="color:#ae81ff">1</span>
</span></span></code></pre></div><p>Just hit <code>make clean</code>.<br>
Again run <code>make -f Makefile-libbz2_so</code>.</p>
<h2 id="618-binutils-234">6.18. Binutils-2.34</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ make -k check
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>make<span style="color:#f92672">[</span>5<span style="color:#f92672">]</span>: *** <span style="color:#f92672">[</span>Makefile:2565: check-DEJAGNU<span style="color:#f92672">]</span> Error <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>make<span style="color:#f92672">[</span>5<span style="color:#f92672">]</span>: Leaving directory <span style="color:#e6db74">&#39;/sources/binutils-2.34/build_6.18/ld&#39;</span>
</span></span><span style="display:flex;"><span>make<span style="color:#f92672">[</span>4<span style="color:#f92672">]</span>: *** <span style="color:#f92672">[</span>Makefile:1902: check-am<span style="color:#f92672">]</span> Error <span style="color:#ae81ff">2</span>
</span></span><span style="display:flex;"><span>make<span style="color:#f92672">[</span>4<span style="color:#f92672">]</span>: Leaving directory <span style="color:#e6db74">&#39;/sources/binutils-2.34/build_6.18/ld&#39;</span>
</span></span><span style="display:flex;"><span>make<span style="color:#f92672">[</span>3<span style="color:#f92672">]</span>: *** <span style="color:#f92672">[</span>Makefile:1771: check-recursive<span style="color:#f92672">]</span> Error <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>make<span style="color:#f92672">[</span>3<span style="color:#f92672">]</span>: Leaving directory <span style="color:#e6db74">&#39;/sources/binutils-2.34/build_6.18/ld&#39;</span>
</span></span><span style="display:flex;"><span>make<span style="color:#f92672">[</span>2<span style="color:#f92672">]</span>: *** <span style="color:#f92672">[</span>Makefile:1904: check<span style="color:#f92672">]</span> Error <span style="color:#ae81ff">2</span>
</span></span><span style="display:flex;"><span>make<span style="color:#f92672">[</span>2<span style="color:#f92672">]</span>: Leaving directory <span style="color:#e6db74">&#39;/sources/binutils-2.34/build_6.18/ld&#39;</span>
</span></span><span style="display:flex;"><span>make<span style="color:#f92672">[</span>1<span style="color:#f92672">]</span>: *** <span style="color:#f92672">[</span>Makefile:7568: check-ld<span style="color:#f92672">]</span> Error <span style="color:#ae81ff">2</span>
</span></span><span style="display:flex;"><span>make<span style="color:#f92672">[</span>1<span style="color:#f92672">]</span>: Leaving directory <span style="color:#e6db74">&#39;/sources/binutils-2.34/build_6.18&#39;</span>
</span></span><span style="display:flex;"><span>make: *** <span style="color:#f92672">[</span>Makefile:2222: <span style="color:#66d9ef">do</span>-check<span style="color:#f92672">]</span> Error <span style="color:#ae81ff">2</span>
</span></span></code></pre></div><p>As I research these are few common errors But as I have not found any solution So I jump on to the next step as suggested in various places.</p>
<p><code>make tooldir=/usr install</code></p>
<p>If you get any solution of above error, Feel free to comment below.</p>
<h2 id="625-gcc-920">6.25. GCC-9.2.0</h2>
<h3 id="error-1-3">Error 1:</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>make: *** <span style="color:#f92672">[</span>Makefile:2295: <span style="color:#66d9ef">do</span>-check<span style="color:#f92672">]</span> Error <span style="color:#ae81ff">2</span>
</span></span></code></pre></div><p>I ignored this and move to next steps.</p>
<h3 id="error-2-got-no-output-with-below-command">Error 2: Got no output with below command:</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>echo <span style="color:#e6db74">&#39;int main(){}&#39;</span> &gt; dummy.c
</span></span><span style="display:flex;"><span>cc dummy.c -v -Wl,--verbose &amp;&gt; dummy.log
</span></span><span style="display:flex;"><span>readelf -l a.out | grep <span style="color:#e6db74">&#39;: /lib&#39;</span>
</span></span></code></pre></div><p>Performed below steps as mentioned on this link <a href="https://stackoverflow.com/a/48289145">https://stackoverflow.com/a/48289145</a>:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>gcc -dumpspecs | sed -e <span style="color:#e6db74">&#39;s@/tools@@g&#39;</span> &gt; <span style="color:#e6db74">`</span>dirname <span style="color:#66d9ef">$(</span>gcc --print-libgcc-file-name<span style="color:#66d9ef">)</span><span style="color:#e6db74">`</span>/specs
</span></span></code></pre></div><p>Again perform above command:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>echo <span style="color:#e6db74">&#39;int main(){}&#39;</span> &gt; dummy.c
</span></span><span style="display:flex;"><span>$ cc dummy.c -v -Wl,--verbose &amp;&gt; dummy.log
</span></span><span style="display:flex;"><span>readelf -l a.out | grep <span style="color:#e6db74">&#39;: /lib&#39;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>     <span style="color:#f92672">[</span>Requesting program interpreter: /lib64/ld-linux-x86-64.so.2<span style="color:#f92672">]</span>
</span></span></code></pre></div><h2 id="641-perl-5301">6.41. Perl-5.30.1</h2>
<h3 id="error-7">Error:</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>erlio.c:<span style="color:#f92672">(</span>.text+0x91b<span style="color:#f92672">)</span>: undefined reference to <span style="color:#e6db74">`</span>pthread_getspecific<span style="color:#e6db74">&#39;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">/usr/bin/ld: perlio.o:perlio.c:(.text+0x44e4): more undefined references to `pthread_getspecific&#39;</span> follow
</span></span><span style="display:flex;"><span>collect2: error: ld returned <span style="color:#ae81ff">1</span> exit status
</span></span><span style="display:flex;"><span>make: *** <span style="color:#f92672">[</span>makefile:364: lib/buildcustomize.pl<span style="color:#f92672">]</span> Error <span style="color:#ae81ff">1</span>
</span></span></code></pre></div><p>Solution which suggested here <a href="https://www.linuxquestions.org/questions/linux-from-scratch-13/errors-with-6-40-perl-5-28-0-a-4175642138/">https://www.linuxquestions.org/questions/linux-from-scratch-13/errors-with-6-40-perl-5-28-0-a-4175642138/</a> It worked for me.</p>
<p>it&rsquo;s due to not having deleted the extracted Perl-5.28.0 directory after Chapter 5. I deleted the folder. Again untar the file.</p>
<h2 id="84-using-grub-to-set-up-the-boot-process">8.4. Using GRUB to Set Up the Boot Process</h2>
<p><strong>NOTE</strong>: I have not performed this section, Becuase I am going to use my host system&rsquo;s (Ubuntu 14.04) GRUB bootloader. Just go to another terminal of host system and hit below command.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>sudo update-grub2
</span></span></code></pre></div><p>After this again go to old terminal(LFS) and proceed with next step (The End).</p>
<p>Please comment below if you facing any issue.</p>
<p>Thanks</p>
]]></content:encoded>
    </item>
    <item>
      <title>[Part 4] Setup Grafana With Prometheus</title>
      <link>https://ashish.one/blogs/setup-grafana-with-prometheus/</link>
      <pubDate>Fri, 03 Apr 2020 21:32:48 +0530</pubDate>
      <guid>https://ashish.one/blogs/setup-grafana-with-prometheus/</guid>
      <description>&lt;p&gt;As you know Prometheus already having UI (&lt;code&gt;localhost:9090&lt;/code&gt;). But it is not enough to give you better visualization on one screen. For better visualization and a graphical representation, we are going to use Grafana.&lt;/p&gt;
&lt;h2 id=&#34;what-is-grafana&#34;&gt;What is Grafana?&lt;/h2&gt;
&lt;p&gt;As &lt;a href=&#34;https://grafana.com&#34;&gt;grafana.com&lt;/a&gt; says&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;”Grafana is the open-source analytics and monitoring solution for every database.”&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This means Grafana is an independent tool for analytics and monitor which gives your various types of Graphs. It is not restricted to Prometheus DB only, You can use mostly any Databases like MySQL, Elasticsearch, etc. So you can visualize different data points from the different databases on one screen. This is the flexibility and power Grafana provides.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>As you know Prometheus already having UI (<code>localhost:9090</code>). But it is not enough to give you better visualization on one screen. For better visualization and a graphical representation, we are going to use Grafana.</p>
<h2 id="what-is-grafana">What is Grafana?</h2>
<p>As <a href="https://grafana.com">grafana.com</a> says</p>
<blockquote>
<p><strong>”Grafana is the open-source analytics and monitoring solution for every database.”</strong></p>
</blockquote>
<p>This means Grafana is an independent tool for analytics and monitor which gives your various types of Graphs. It is not restricted to Prometheus DB only, You can use mostly any Databases like MySQL, Elasticsearch, etc. So you can visualize different data points from the different databases on one screen. This is the flexibility and power Grafana provides.</p>
<p>Grafana works on TSDB(Time Series Database) or Your data should be save in time series manner. Check explaination <a href="https://grafana.com/docs/grafana/latest/guides/timeseries/">here</a>.</p>
<p>It has an alert system. You can configure an alert on Grafana itself for any Metric.</p>
<h2 id="why-grafana">Why Grafana?</h2>
<ol>
<li>Open-source of course freely Available</li>
<li>It is constantly contributed by the community. It is stable and used by many good brands.</li>
<li>Good community support and well documented.</li>
<li>You do not need any big infrastructure to get started.</li>
<li>Lots of pre-build Grafana dashboards already available and build by the community.  So it will be a rare case where you have to build your dashboard.</li>
</ol>
<h2 id="my-local-system-configuration">My local system configuration:</h2>
<ul>
<li>8GB RAM</li>
<li>Ubuntu 18.04 LTS</li>
</ul>
<p>You can check <a href="https://grafana.com/docs/grafana/latest/installation/requirements/">here</a> your system requirement according to your Operating System. Also, They explained different ways to install Grafana for different OS.</p>
<h2 id="setup-grafana">Setup Grafana</h2>
<h3 id="installation">Installation</h3>
<p>Grafana has two types of Software:</p>
<ol>
<li><strong>Enterprise Release</strong></li>
<li><strong>Open-Sources Software(OSS) or Community Release</strong></li>
</ol>
<p>We are going to install OSS Release.</p>
<h4 id="step-1-install-apt-transport-https">Step 1: Install <code>apt-transport-https</code></h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo apt-get install -y apt-transport-https
</span></span></code></pre></div><p><img loading="lazy" src="/img/grafana-setup/apt-transport-https.png" alt="apt-transport-https"  />
</p>
<h4 id="step-2-install-wget">Step 2: Install <code>wget</code></h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo apt-get install -y software-properties-common wget
</span></span></code></pre></div><p><img loading="lazy" src="/img/grafana-setup/install-wget.png" alt="install-wget"  />
</p>
<h4 id="step-3-add-key">Step 3: Add key</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
</span></span></code></pre></div><h4 id="step-4-add-apt-repository">Step 4: Add <code>apt</code> Repository</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo add-apt-repository <span style="color:#e6db74">&#34;deb https://packages.grafana.com/oss/deb stable main&#34;</span>
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>OK
</span></span></code></pre></div><h4 id="step-5-update--install">Step 5: Update &amp; Install</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo apt-get update
</span></span><span style="display:flex;"><span>$ sudo apt-get install grafana
</span></span></code></pre></div><p><img loading="lazy" src="/img/grafana-setup/install-grafana.png" alt="install-grafana"  />
</p>
<h4 id="step-6-start-grafana-server">Step 6: Start <code>grafana-server</code></h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo systemctl daemon-reload  
</span></span><span style="display:flex;"><span>$ sudo systemctl start grafana-server  
</span></span><span style="display:flex;"><span>$ sudo systemctl status grafana-server  
</span></span></code></pre></div><p><img loading="lazy" src="/img/grafana-setup/grafana-status.png" alt="grafana-status"  />
</p>
<h4 id="step-7-visit-localhost3000">Step 7: Visit <code>localhost:3000</code></h4>
<p><img loading="lazy" src="/img/grafana-setup/grafana-browser.png" alt="grafana-browser"  />
</p>
<h3 id="install-with-docker">Install with Docker</h3>
<p>Ignore this part if you not using docker.</p>
<pre tabindex="0"><code>docker run -d -p 3000:3000 grafana/grafana
</code></pre><p>visit <code>localhost:3000</code>.</p>
<p>We have successfully installed Grafana. Let&rsquo;s configure with Prometheus.</p>
<h2 id="configure-with-prometheus">Configure with Prometheus</h2>
<p>We already setup Prometheus in <a href="https://ashish.one/blogs/setup-prometheus-and-exporters/">part 1</a>. Now I am considering your Prometheus and Node exporter are running on port <code>9090</code> &amp; <code>9100</code> respectively.</p>
<h3 id="setup-grafana----prometheus">Setup Grafana &lt;&ndash;&gt; Prometheus</h3>
<h4 id="step-1-login-on-grafana">Step 1: Login on Grafana</h4>
<p>Visit <code>localhost:3000</code>. 3000 is the default port of Grafana, However, you can run on any port. To change the port see the <a href="https://grafana.com/docs/grafana/latest/installation/configuration/">configuration</a>.</p>
<p>Login into Grafana with default Credentials:</p>
<p><strong>Username</strong>:<code>admin</code><br>
<strong>Password</strong>:<code>admin</code></p>
<p>Now it will ask you to change your password. Once done, Click on <code>save</code>, You will be redirect on the dashboard.</p>
<p><img loading="lazy" src="/img/grafana-setup/grafana-dashboard.png" alt="grafana-dashboard"  />
</p>
<h4 id="step-2-add-data-source">Step 2: Add Data Source</h4>
<p>Goto Sidebar &amp; Navigate:</p>
<p><strong><em>Configuration -&gt; Data Sources</em></strong></p>
<p><img loading="lazy" src="/img/grafana-setup/datasource.png" alt="datasource"  />
</p>
<p>click on <code>Add data source</code>.
<img loading="lazy" src="/img/grafana-setup/prometheus-data-source.png" alt="prometheus-data-source"  />
</p>
<p>Search for <code>Prometheus</code> &amp; click on <code>Select</code>.</p>
<p>Add Prometheus endpoint in <code>URL</code> and click on <code>save &amp; Test</code>.</p>
<p><img loading="lazy" src="/img/grafana-setup/grafana-prometheus-config.png" alt="grafana-prometheus-config"  />
</p>
<p>You will get the notification for success. Here we have successfully integrated Grafana and Prometheus.</p>
<h4 id="step-3-add-dashboard">Step 3: Add Dashboard</h4>
<p>Here we have two option available:</p>
<ol>
<li><strong><em>Create your Dashboard</em></strong></li>
<li><strong><em>Import any pre-build Dashboard</em></strong></li>
</ol>
<p>We will go with the second option because that is the beauty of community :) People already build a dashboard for various stacks.</p>
<p>You can search for Dashboard from <a href="https://grafana.com/grafana/dashboards">https://grafana.com/grafana/dashboards</a> as per your requirement.</p>
<p>Here is the link for Node exporter dashboard: <a href="https://grafana.com/grafana/dashboards/1860">https://grafana.com/grafana/dashboards/1860</a></p>
<p>Here Dashboard ID is <code>1860</code>. Every dashboard which contributed in Grafana has unique ID. You can just import any dashboard by inserting the ID.</p>
<p><img loading="lazy" src="/img/grafana-setup/node-exporter-dashboard.png" alt="node-exporter-dashboard"  />
</p>
<p>On Grafana Goto sidebar &amp; Navigate:</p>
<p><strong><em>+(Plus/Add sign) -&gt; Import</em></strong></p>
<p>Enter Dashboard Id and click on <code>load</code>. After that<br>
<img loading="lazy" src="/img/grafana-setup/dashboard-id.png" alt="dashboard-id"  />
</p>
<p>Enter the Name &amp; select Prometheus on label <code>Prometheus</code> as shown in below image.
<img loading="lazy" src="/img/grafana-setup/dashboard-config.png" alt="dashboard-config"  />
</p>
<p>Click on <code>Import</code>.</p>
<p>Your Dashboard will be ready.</p>
<p><img loading="lazy" src="/img/grafana-setup/node-dashboard.png" alt="node-dashboard"  />
</p>
<p>Here we have successfully integrated the Grafana with Prometheus. You can explore more features of Grafana like Alerts, Users, etc.</p>
<p>For the alerting system, I prefer Prometheus Alertmanager only. You can check more details on the Alertmanager in <a href="https://ashish.one/blogs/setup-alertmanager/">part 2</a>. It gives you more control and advanced feature.</p>
<p>But every tool has use cases and built for special purposes. You can choose according to your requirements.</p>
<p><strong>In case of any confusion or issues leave comments below :)</strong></p>
]]></content:encoded>
    </item>
    <item>
      <title>Install python3.6, pip3.6, pipenv on  Ubuntu 14.04 LTS</title>
      <link>https://ashish.one/blogs/install-python3.6-pip3.6-pipenv-on-ubuntu14.04/</link>
      <pubDate>Thu, 02 Apr 2020 17:52:19 +0530</pubDate>
      <guid>https://ashish.one/blogs/install-python3.6-pip3.6-pipenv-on-ubuntu14.04/</guid>
      <description>&lt;h2 id=&#34;prerequisite&#34;&gt;Prerequisite&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;OS:&lt;/strong&gt; Ubuntu 14.04 LTS&lt;br&gt;
&lt;strong&gt;Processor:&lt;/strong&gt; 64 Bit&lt;br&gt;
&lt;strong&gt;RAM:&lt;/strong&gt; 2 GB&lt;/p&gt;
&lt;h2 id=&#34;1-install-python36-from-source&#34;&gt;1. Install python3.6 From source&lt;/h2&gt;
&lt;h3 id=&#34;step-11-compile&#34;&gt;Step 1.1: Compile&lt;/h3&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ tar -xvf Python-3.6.3.tgz
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ cd Python-3.6.3
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ sudo ./configure --enable-optimizations
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ sudo make install
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;step-12-check&#34;&gt;Step 1.2: Check&lt;/h3&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ python3.6 --version
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;2-install-pip36&#34;&gt;2. Install &lt;code&gt;pip3.6&lt;/code&gt;&lt;/h2&gt;
&lt;h3 id=&#34;step-21-download-pip&#34;&gt;Step 2.1: Download pip&lt;/h3&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ wget https://bootstrap.pypa.io/get-pip.py
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;step-22-execute&#34;&gt;Step 2.2: Execute&lt;/h3&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ sudo python3.6 get-pip.py
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;step-23-if-you-got-below-error&#34;&gt;Step 2.3: If you Got below error&lt;/h3&gt;
&lt;h4 id=&#34;error--zlib-not-available&#34;&gt;Error  &lt;code&gt;zlib not available&lt;/code&gt;&lt;/h4&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Traceback &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;most recent call last&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  File &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;get-pip.py&amp;#34;&lt;/span&gt;, line 22711, in &amp;lt;module&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    main&lt;span style=&#34;color:#f92672&#34;&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  File &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;get-pip.py&amp;#34;&lt;/span&gt;, line 198, in main
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    bootstrap&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;tmpdir&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;tmpdir&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  File &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;get-pip.py&amp;#34;&lt;/span&gt;, line 82, in bootstrap
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    from pip._internal.cli.main import main as pip_entry_point
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;zipimport.ZipImportError: can&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&amp;#39;&lt;/span&gt;t decompress data; zlib not available
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;step-231-install-zlib&#34;&gt;Step 2.3.1: Install &lt;code&gt;zlib&lt;/code&gt;:&lt;/h4&gt;
&lt;h4 id=&#34;install-with-some-other-dependency&#34;&gt;Install with some other dependency&lt;/h4&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;OR&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h2 id="prerequisite">Prerequisite</h2>
<p><strong>OS:</strong> Ubuntu 14.04 LTS<br>
<strong>Processor:</strong> 64 Bit<br>
<strong>RAM:</strong> 2 GB</p>
<h2 id="1-install-python36-from-source">1. Install python3.6 From source</h2>
<h3 id="step-11-compile">Step 1.1: Compile</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
</span></span><span style="display:flex;"><span>$ tar -xvf Python-3.6.3.tgz
</span></span><span style="display:flex;"><span>$ cd Python-3.6.3
</span></span><span style="display:flex;"><span>$ sudo ./configure --enable-optimizations
</span></span><span style="display:flex;"><span>$ sudo make install
</span></span></code></pre></div><h3 id="step-12-check">Step 1.2: Check</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ python3.6 --version
</span></span></code></pre></div><h2 id="2-install-pip36">2. Install <code>pip3.6</code></h2>
<h3 id="step-21-download-pip">Step 2.1: Download pip</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ wget https://bootstrap.pypa.io/get-pip.py
</span></span></code></pre></div><h3 id="step-22-execute">Step 2.2: Execute</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo python3.6 get-pip.py
</span></span></code></pre></div><h3 id="step-23-if-you-got-below-error">Step 2.3: If you Got below error</h3>
<h4 id="error--zlib-not-available">Error  <code>zlib not available</code></h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>Traceback <span style="color:#f92672">(</span>most recent call last<span style="color:#f92672">)</span>:
</span></span><span style="display:flex;"><span>  File <span style="color:#e6db74">&#34;get-pip.py&#34;</span>, line 22711, in &lt;module&gt;
</span></span><span style="display:flex;"><span>    main<span style="color:#f92672">()</span>
</span></span><span style="display:flex;"><span>  File <span style="color:#e6db74">&#34;get-pip.py&#34;</span>, line 198, in main
</span></span><span style="display:flex;"><span>    bootstrap<span style="color:#f92672">(</span>tmpdir<span style="color:#f92672">=</span>tmpdir<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>  File <span style="color:#e6db74">&#34;get-pip.py&#34;</span>, line 82, in bootstrap
</span></span><span style="display:flex;"><span>    from pip._internal.cli.main import main as pip_entry_point
</span></span><span style="display:flex;"><span>zipimport.ZipImportError: can<span style="color:#960050;background-color:#1e0010">&#39;</span>t decompress data; zlib not available
</span></span></code></pre></div><h4 id="step-231-install-zlib">Step 2.3.1: Install <code>zlib</code>:</h4>
<h4 id="install-with-some-other-dependency">Install with some other dependency</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev
</span></span></code></pre></div><p>OR</p>
<h4 id="you-can-install-just-zlib1g-dev">You can install just <code>zlib1g-dev</code></h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo apt-get install zlib1g-dev
</span></span></code></pre></div><h4 id="chances-to-get-error">Chances to get error</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ zlib1g-dev is already the newest version.
</span></span></code></pre></div><h4 id="just-upgrade-it-if-not-new">Just upgrade it if not new</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo apt-get upgrade zlib1g-dev
</span></span></code></pre></div><h3 id="step-232-now-again-try">Step 2.3.2: Now again try</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo python3.6 get-pip.py
</span></span></code></pre></div><h4 id="if-you-get-same-error-again-then-go-for-below-steps">If you get same error again, Then go for below steps:</h4>
<p>Open <code>Modules/Setup</code> from folder &lsquo;Python-3.6.3&rsquo; which we extracted on Step 1.1</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo vim Modules/Setup
</span></span></code></pre></div><h4 id="uncomment-the-below-line-or-jump-on-line-no-366">Uncomment the below line or jump on line no. 366</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>zlib zlibmodule.c -I<span style="color:#66d9ef">$(</span>prefix<span style="color:#66d9ef">)</span>/include -L<span style="color:#66d9ef">$(</span>exec_prefix<span style="color:#66d9ef">)</span>/lib -lz
</span></span></code></pre></div><h4 id="now-we-need-to-again-perform-few-operation-from-__steps-11__">Now we need to again perform few operation from <strong>steps 1.1</strong></h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo ./configure
</span></span><span style="display:flex;"><span>$ sudo make install
</span></span></code></pre></div><h4 id="now-run-again--it-should-be-work">Now run again &amp; It should be work</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo python3.6 get-pip.py
</span></span></code></pre></div><h3 id="step-24-lets-install-pipenv-for-testing-purpose">Step 2.4: Let&rsquo;s Install <code>pipenv</code> for testing purpose:</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo pip3.6 install pipenv
</span></span></code></pre></div>]]></content:encoded>
    </item>
    <item>
      <title>Covid19 Data Source for India &amp; Global</title>
      <link>https://ashish.one/blogs/covid19-data-source-and-endpoints-india-global/</link>
      <pubDate>Fri, 27 Mar 2020 20:04:13 +0530</pubDate>
      <guid>https://ashish.one/blogs/covid19-data-source-and-endpoints-india-global/</guid>
      <description>&lt;p&gt;Hi Guys, I am trying to listing all data source &amp;amp; endpoints for COVID19 - India as well as Global. It can contains offical or unofficial APIs. Anyone is working on any COVID19 project for India, Can use these sources.&lt;/p&gt;
&lt;h2 id=&#34;apis&#34;&gt;APIs&lt;/h2&gt;
&lt;h3 id=&#34;1-github-amodmapi-covid19-in-india&#34;&gt;1. Github: amodm/api-covid19-in (India)&lt;/h3&gt;
&lt;h4 id=&#34;repo&#34;&gt;Repo:&lt;/h4&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;https://github.com/amodm/api-covid19-in
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&#34;apis-available&#34;&gt;APIs available:&lt;/h4&gt;
&lt;h5 id=&#34;statewise-data&#34;&gt;Statewise Data&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;StateWise&lt;/li&gt;
&lt;li&gt;StateWise History&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id=&#34;medica&#34;&gt;Medica&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;Hospital Stats&lt;/li&gt;
&lt;li&gt;Bed Stats&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id=&#34;contacts&#34;&gt;Contacts&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;HelpLines&lt;/li&gt;
&lt;li&gt;Contacts&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id=&#34;patient&#34;&gt;Patient&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;Tracing&lt;/li&gt;
&lt;li&gt;History&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;sources&#34;&gt;Sources&lt;/h4&gt;
&lt;p&gt;The source is both types of official &amp;amp; Unofficial.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Hi Guys, I am trying to listing all data source &amp; endpoints for COVID19 - India as well as Global. It can contains offical or unofficial APIs. Anyone is working on any COVID19 project for India, Can use these sources.</p>
<h2 id="apis">APIs</h2>
<h3 id="1-github-amodmapi-covid19-in-india">1. Github: amodm/api-covid19-in (India)</h3>
<h4 id="repo">Repo:</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>https://github.com/amodm/api-covid19-in
</span></span></code></pre></div><h4 id="apis-available">APIs available:</h4>
<h5 id="statewise-data">Statewise Data</h5>
<ul>
<li>StateWise</li>
<li>StateWise History</li>
</ul>
<h5 id="medica">Medica</h5>
<ul>
<li>Hospital Stats</li>
<li>Bed Stats</li>
</ul>
<h5 id="contacts">Contacts</h5>
<ul>
<li>HelpLines</li>
<li>Contacts</li>
</ul>
<h5 id="patient">Patient</h5>
<ul>
<li>Tracing</li>
<li>History</li>
</ul>
<h4 id="sources">Sources</h4>
<p>The source is both types of official &amp; Unofficial.</p>
<h5 id="official">Official</h5>
<ul>
<li>Post Mar 15, data is from <a href="https://www.mohfw.gov.in/">The Ministry of Health &amp; Family Welfare</a></li>
<li>Pre  Mar 15, data is sourced from <a href="https://github.com/datameet/covid19/tree/eb1cc65657929abe12ca59f0e754bef4bc562d7a/mohfw-backup">datameet/covid19</a></li>
<li>Hospital &amp; bed data: <a href="https://api.steinhq.com/v1/storages/5e732accb88d3d04ae0815ae/StateWiseHealthCapacity">https://api.steinhq.com/v1/storages/5e732accb88d3d04ae0815ae/StateWiseHealthCapacity</a></li>
<li>ICMR testing stats API: <a href="https://api.steinhq.com/v1/storages/5e6e3e9fb88d3d04ae08158c/ICMRTestData">https://api.steinhq.com/v1/storages/5e6e3e9fb88d3d04ae08158c/ICMRTestData</a></li>
</ul>
<h5 id="unofficial">Unofficial</h5>
<ul>
<li>The awesome volunteer driven patient tracing data <a href="https://www.covid19india.org/">covid19india.org</a></li>
<li>API (NLP): <a href="http://coronatravelhistory.pythonanywhere.com/">http://coronatravelhistory.pythonanywhere.com/</a></li>
<li>API (Travel history): <a href="https://api.covid19india.org/travel_history.json">https://api.covid19india.org/travel_history.json</a></li>
</ul>
<h3 id="2-github-ashishtiwari1993india_mohfwgovin_scrape_covid19_statewise_status-india">2. Github: ashishtiwari1993/india_mohfw.gov.in_scrape_covid19_statewise_status (India)</h3>
<p>Scraping <a href="https://mohfw.gov.in">https://mohfw.gov.in</a> to extract the statewise data.</p>
<h4 id="repo-1">Repo:</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>https://github.com/ashishtiwari1993/india_mohfw.gov.in_scrape_covid19_statewise_status
</span></span></code></pre></div><h4 id="apis-available-1">APIs available:</h4>
<h5 id="statewise-status">Statewise status</h5>
<ul>
<li>Total confirmed case</li>
<li>Counts</li>
<li>Deaths</li>
</ul>
<h4 id="sources-1">Sources</h4>
<p>Scraping from offical site of The Ministry of Health and Family Welfare.</p>
<h3 id="3-github-novelcovidapi-global">3. Github: NovelCOVID/API (Global)</h3>
<h4 id="repo-2">Repo:</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>https://github.com/NovelCOVID/API
</span></span></code></pre></div><h4 id="apis-available-2">APIs available:</h4>
<p>It is global data source. You will get all information for any country.</p>
<h4 id="sources-2">Sources</h4>
<ul>
<li><a href="https://www.worldometers.info/coronavirus/">Worldometers</a></li>
</ul>
<h3 id="4-github-cssegisanddatacovid-19-global">4. Github: CSSEGISandData/COVID-19 (Global)</h3>
<p>This is the data repository for the 2019 Novel Coronavirus Visual Dashboard operated by the Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE). Also, Supported by ESRI Living Atlas Team and the Johns Hopkins University Applied Physics Lab (JHU APL).</p>
<h4 id="repo-3">Repo:</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>https://github.com/CSSEGISandData/COVID-19
</span></span></code></pre></div><h4 id="data-available">Data Available</h4>
<p>CSVs are available in time series manner. Information is available about all country.</p>
<h2 id="sources-3">Sources</h2>
<ul>
<li>World Health Organization (WHO): <a href="https://www.who.int/">https://www.who.int/</a></li>
<li>DXY.cn. Pneumonia. 2020. <a href="http://3g.dxy.cn/newh5/view/pneumonia">http://3g.dxy.cn/newh5/view/pneumonia</a>.</li>
<li>BNO News: <a href="https://bnonews.com/index.php/2020/02/the-latest-coronavirus-cases/">https://bnonews.com/index.php/2020/02/the-latest-coronavirus-cases/</a></li>
<li>National Health Commission of the People’s Republic of China (NHC):
<a href="http://www.nhc.gov.cn/xcs/yqtb/list_gzbd.shtml">http://www.nhc.gov.cn/xcs/yqtb/list_gzbd.shtml</a></li>
<li>China CDC (CCDC): <a href="http://weekly.chinacdc.cn/news/TrackingtheEpidemic.htm">http://weekly.chinacdc.cn/news/TrackingtheEpidemic.htm</a></li>
<li>Hong Kong Department of Health: <a href="https://www.chp.gov.hk/en/features/102465.html">https://www.chp.gov.hk/en/features/102465.html</a></li>
<li>Macau Government: <a href="https://www.ssm.gov.mo/portal/">https://www.ssm.gov.mo/portal/</a></li>
<li>Taiwan CDC: <a href="https://sites.google.com/cdc.gov.tw/2019ncov/taiwan?authuser=0">https://sites.google.com/cdc.gov.tw/2019ncov/taiwan?authuser=0</a></li>
<li>US CDC: <a href="https://www.cdc.gov/coronavirus/2019-ncov/index.html">https://www.cdc.gov/coronavirus/2019-ncov/index.html</a></li>
<li>Government of Canada: <a href="https://www.canada.ca/en/public-health/services/diseases/coronavirus.html">https://www.canada.ca/en/public-health/services/diseases/coronavirus.html</a></li>
<li>Australia Government Department of Health: <a href="https://www.health.gov.au/news/coronavirus-update-at-a-glance">https://www.health.gov.au/news/coronavirus-update-at-a-glance</a></li>
<li>European Centre for Disease Prevention and Control (ECDC): <a href="https://www.ecdc.europa.eu/en/geographical-distribution-2019-ncov-cases">https://www.ecdc.europa.eu/en/geographical-distribution-2019-ncov-cases</a></li>
<li>Ministry of Health Singapore (MOH): <a href="https://www.moh.gov.sg/covid-19">https://www.moh.gov.sg/covid-19</a></li>
<li>Italy Ministry of Health: <a href="http://www.salute.gov.it/nuovocoronavirus">http://www.salute.gov.it/nuovocoronavirus</a></li>
<li>1Point3Arces: <a href="https://coronavirus.1point3acres.com/en">https://coronavirus.1point3acres.com/en</a></li>
<li>WorldoMeters: <a href="https://www.worldometers.info/coronavirus/">https://www.worldometers.info/coronavirus/</a></li>
</ul>
]]></content:encoded>
    </item>
    <item>
      <title>Golang basics &amp; Handling 100k hourly webhooks with golang @MimePost</title>
      <link>https://ashish.one/talks/golang-basics-and-send-100k-hourly-webhooks-with-golang-mimepost/</link>
      <pubDate>Wed, 11 Mar 2020 00:12:30 +0530</pubDate>
      <guid>https://ashish.one/talks/golang-basics-and-send-100k-hourly-webhooks-with-golang-mimepost/</guid>
      <description>&lt;h2 id=&#34;what-this-talk-about&#34;&gt;What this talk about?&lt;/h2&gt;
&lt;p&gt;I am working on Golang for the last 1 year from the published date. I have shared some basics of Golang.&lt;/p&gt;
&lt;p&gt;Also, shared What are the pain points developers face when they migrate from any other language (Especially from web language like PHP) to Golang?&lt;/p&gt;
&lt;p&gt;I have explained the Webhook architecture of MimePost And how we sending 100k Request hourly( Though Benchmark proves we can scale up to 500k).&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h2 id="what-this-talk-about">What this talk about?</h2>
<p>I am working on Golang for the last 1 year from the published date. I have shared some basics of Golang.</p>
<p>Also, shared What are the pain points developers face when they migrate from any other language (Especially from web language like PHP) to Golang?</p>
<p>I have explained the Webhook architecture of MimePost And how we sending 100k Request hourly( Though Benchmark proves we can scale up to 500k).</p>
<p>Shown some immature code which given me a better understanding of 100% CPU utilization and How I waste my major time to debug on silly things.</p>
<p>Shared one of our error and it&rsquo;s solutions related to How you can avoid race conditions on &ldquo;map&rdquo; type variables.</p>
<h2 id="slides">Slides</h2>
<div id="Container"
 style="padding-bottom:56.25%; position:relative; display:block; width: 100%">
 <iframe id="googleSlideIframe"
  width="100%" height="100%"
  src="https://docs.google.com/presentation/d/e/2PACX-1vQExSl-gRPoA9hC6qXuqrjwiQVHAanDieZN_5GpV2Lw9cuxjsVFEN_wkTThqpQwZ36vJz4zwmTvV7cC/embed?start=false&amp;loop=false&amp;delayms=3000"
  frameborder="0" allowfullscreen=""
  style="position:absolute; top:0; left: 0"></iframe>
</div>

<h2 id="talk-video">Talk Video</h2>


    
    <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/ZjOcwoCkkog?autoplay=0&controls=1&end=0&loop=0&mute=0&start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"
      ></iframe>
    </div>

<h2 id="demo---1">Demo - 1</h2>
<p>This code will make 100% CPU utilization and <code>forever()</code> function not going to share any single CPU time with <code>anotherGoroutine()</code></p>
<script src="https://gist.github.com/ashishtiwari1993/00b2a56ac8f5b39d3229d723e58815bc.js"></script>

<h2 id="demo---2">Demo - 2</h2>
<p>Reproduce Golang &ldquo;fatal error: concurrent map writes&rdquo; &amp; Solution. To reproduce comment Mutex related all operation like line no. 12, 30, 32, 44, 46. Mutex is use to prevent race condition which generates this error.</p>
<script src="https://gist.github.com/ashishtiwari1993/d494b71ac264184ba46ced1bf2114c30.js"></script>

<p>Find more details on this <a href="https://ashish.one/blogs/fatal-error-concurrent-map-writes/">blog</a>.</p>
<h4 id="feel-free-to-comment-below-if-you-have-any-doubts-or-suggestion-about-this-talk">Feel free to comment below, If you have any doubts or suggestion about this talk.</h4>
]]></content:encoded>
    </item>
    <item>
      <title>[SOLVED] Golang fatal error: concurrent map writes</title>
      <link>https://ashish.one/blogs/fatal-error-concurrent-map-writes/</link>
      <pubDate>Tue, 04 Feb 2020 01:14:03 +0530</pubDate>
      <guid>https://ashish.one/blogs/fatal-error-concurrent-map-writes/</guid>
      <description>&lt;p&gt;&lt;img loading=&#34;lazy&#34; src=&#34;https://ashish.one/img/golang/concurrent_map_writes.jpg&#34; alt=&#34;concurrent_map_writes&#34;  /&gt;
&lt;/p&gt;
&lt;h2 id=&#34;the-problem&#34;&gt;The Problem:&lt;/h2&gt;
&lt;p&gt;Suddenly got below errors which killed my daemon:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;fatal error: concurrent map writes
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;goroutine &lt;span style=&#34;color:#ae81ff&#34;&gt;646&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;running&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;runtime.throw&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;0x75fd38, 0x15&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        /usr/local/go/src/runtime/panic.go:774 +0x72 fp&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0xc000315e60 sp&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0xc000315e30 pc&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0x42ecf2
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;runtime.mapdelete_fast64&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;0x6f0800, 0xc00008ad50, 0x2b3e&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;goroutine &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;sleep&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;runtime.goparkunlock&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;...&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        /usr/local/go/src/runtime/proc.go:310
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;time.Sleep&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;0x12a05f200&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        /usr/local/go/src/runtime/time.go:105 +0x157
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;webhook/worker.Manager&lt;span style=&#34;color:#f92672&#34;&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;goroutine &lt;span style=&#34;color:#ae81ff&#34;&gt;6&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;IO wait&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;internal/poll.runtime_pollWait&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;0x7fc308de6f08, 0x72, 0x0&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        /usr/local/go/src/runtime/netpoll.go:184 +0x55
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;internal/poll.&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;*pollDesc&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;.wait&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;0xc000110018, 0x72, 0x0, 0x0, 0x75b00b&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        /usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x45
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;internal/poll.&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;*pollDesc&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;.waitRead&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;...&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        /usr/local/go/src/internal/poll/fd_poll_runtime.go:92
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;internal/poll.&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;*FD&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;.Accept&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;0xc000110000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        /usr/local/go/src/internal/poll/fd_unix.go:384 +0x1f8
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;net.&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;*netFD&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;.accept&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;0xc000110000, 0xc000050d50, 0xc000046700, 0x7fc308e426d0&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        /usr/local/go/src/net/fd_unix.go:238 +0x42
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;net.&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;*TCPListener&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;.accept&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;0xc000126000, 0xc000050d80, 0x40dd08, 0x30&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        /usr/local/go/src/net/tcpsock_posix.go:139 +0x32
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;net.&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;*TCPListener&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;.Accept&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;0xc000126000, 0x72f560, 0xc0000f0180, 0x6f4f20, 0x9c00c0&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        /usr/local/go/src/net/tcpsock.go:261 +0x47
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;net/http.&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;*Server&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;.Serve&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;0xc0000f4000, 0x7ccbe0, 0xc000126000, 0x0, 0x0&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        /usr/local/go/src/net/http/server.go:2896 +0x286
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;net/http.&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;*Server&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;.ListenAndServe&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;0xc0000f4000, 0xc0000f4000, 0x8&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        /usr/local/go/src/net/http/server.go:2825 +0xb7
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;net/http.ListenAndServe&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;...&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        /usr/local/go/src/net/http/server.go:3080
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;webhook/handler.HandleRequest&lt;span style=&#34;color:#f92672&#34;&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;expected-behaviour&#34;&gt;Expected behaviour&lt;/h3&gt;
&lt;p&gt;In starting for a few seconds it was working smoothly.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p><img loading="lazy" src="/img/golang/concurrent_map_writes.jpg" alt="concurrent_map_writes"  />
</p>
<h2 id="the-problem">The Problem:</h2>
<p>Suddenly got below errors which killed my daemon:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>fatal error: concurrent map writes
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>goroutine <span style="color:#ae81ff">646</span> <span style="color:#f92672">[</span>running<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>runtime.throw<span style="color:#f92672">(</span>0x75fd38, 0x15<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>        /usr/local/go/src/runtime/panic.go:774 +0x72 fp<span style="color:#f92672">=</span>0xc000315e60 sp<span style="color:#f92672">=</span>0xc000315e30 pc<span style="color:#f92672">=</span>0x42ecf2
</span></span><span style="display:flex;"><span>runtime.mapdelete_fast64<span style="color:#f92672">(</span>0x6f0800, 0xc00008ad50, 0x2b3e<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>goroutine <span style="color:#ae81ff">1</span> <span style="color:#f92672">[</span>sleep<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>runtime.goparkunlock<span style="color:#f92672">(</span>...<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>        /usr/local/go/src/runtime/proc.go:310
</span></span><span style="display:flex;"><span>time.Sleep<span style="color:#f92672">(</span>0x12a05f200<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>        /usr/local/go/src/runtime/time.go:105 +0x157
</span></span><span style="display:flex;"><span>webhook/worker.Manager<span style="color:#f92672">()</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>goroutine <span style="color:#ae81ff">6</span> <span style="color:#f92672">[</span>IO wait<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>internal/poll.runtime_pollWait<span style="color:#f92672">(</span>0x7fc308de6f08, 0x72, 0x0<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>        /usr/local/go/src/runtime/netpoll.go:184 +0x55
</span></span><span style="display:flex;"><span>internal/poll.<span style="color:#f92672">(</span>*pollDesc<span style="color:#f92672">)</span>.wait<span style="color:#f92672">(</span>0xc000110018, 0x72, 0x0, 0x0, 0x75b00b<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>        /usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x45
</span></span><span style="display:flex;"><span>internal/poll.<span style="color:#f92672">(</span>*pollDesc<span style="color:#f92672">)</span>.waitRead<span style="color:#f92672">(</span>...<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>        /usr/local/go/src/internal/poll/fd_poll_runtime.go:92
</span></span><span style="display:flex;"><span>internal/poll.<span style="color:#f92672">(</span>*FD<span style="color:#f92672">)</span>.Accept<span style="color:#f92672">(</span>0xc000110000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>        /usr/local/go/src/internal/poll/fd_unix.go:384 +0x1f8
</span></span><span style="display:flex;"><span>net.<span style="color:#f92672">(</span>*netFD<span style="color:#f92672">)</span>.accept<span style="color:#f92672">(</span>0xc000110000, 0xc000050d50, 0xc000046700, 0x7fc308e426d0<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>        /usr/local/go/src/net/fd_unix.go:238 +0x42
</span></span><span style="display:flex;"><span>net.<span style="color:#f92672">(</span>*TCPListener<span style="color:#f92672">)</span>.accept<span style="color:#f92672">(</span>0xc000126000, 0xc000050d80, 0x40dd08, 0x30<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>        /usr/local/go/src/net/tcpsock_posix.go:139 +0x32
</span></span><span style="display:flex;"><span>net.<span style="color:#f92672">(</span>*TCPListener<span style="color:#f92672">)</span>.Accept<span style="color:#f92672">(</span>0xc000126000, 0x72f560, 0xc0000f0180, 0x6f4f20, 0x9c00c0<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>        /usr/local/go/src/net/tcpsock.go:261 +0x47
</span></span><span style="display:flex;"><span>net/http.<span style="color:#f92672">(</span>*Server<span style="color:#f92672">)</span>.Serve<span style="color:#f92672">(</span>0xc0000f4000, 0x7ccbe0, 0xc000126000, 0x0, 0x0<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>        /usr/local/go/src/net/http/server.go:2896 +0x286
</span></span><span style="display:flex;"><span>net/http.<span style="color:#f92672">(</span>*Server<span style="color:#f92672">)</span>.ListenAndServe<span style="color:#f92672">(</span>0xc0000f4000, 0xc0000f4000, 0x8<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>        /usr/local/go/src/net/http/server.go:2825 +0xb7
</span></span><span style="display:flex;"><span>net/http.ListenAndServe<span style="color:#f92672">(</span>...<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>        /usr/local/go/src/net/http/server.go:3080
</span></span><span style="display:flex;"><span>webhook/handler.HandleRequest<span style="color:#f92672">()</span>
</span></span></code></pre></div><h3 id="expected-behaviour">Expected behaviour</h3>
<p>In starting for a few seconds it was working smoothly.</p>
<p><img loading="lazy" src="/img/golang/Go-Routines_race_condition.png" alt="goroutine_race_condition"  />
</p>
<h3 id="actual-behaviour">Actual behaviour</h3>
<p>After few seconds my service got kill with above mentioned error.</p>
<p><img loading="lazy" src="/img/golang/Go-Routines_race_condition_error.png" alt="goroutine_race_condition_error"  />
</p>
<h2 id="code-overview">Code Overview:</h2>
<p>Initialized one global variable with the type &lsquo;map&rsquo;. Where the key is <code>int</code> and value is <code>channel</code>.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>var ActiveInstances <span style="color:#f92672">=</span> make<span style="color:#f92672">(</span>map<span style="color:#f92672">[</span>int<span style="color:#f92672">](</span>chan string<span style="color:#f92672">))</span>
</span></span></code></pre></div><p>Having two functions</p>
<ol>
<li><code>go SetValue()</code></li>
<li><code>go DeleteValue()</code></li>
</ol>
<h3 id="in-setvalue">In <code>SetValue()</code></h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>ActiveInstances<span style="color:#f92672">[</span>id<span style="color:#f92672">]</span> <span style="color:#f92672">=</span> make<span style="color:#f92672">(</span>chan string, 5<span style="color:#f92672">)</span>
</span></span></code></pre></div><h3 id="in-deletevalue">In <code>DeleteValue()</code></h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>delete<span style="color:#f92672">(</span>ActiveInstances, id<span style="color:#f92672">)</span>
</span></span></code></pre></div><p>Both functions running in multiple goroutines.</p>
<h2 id="observation">Observation:</h2>
<p>The error itself says <code>concurrent map writes</code>, By which I got the idea that something is wrong with my map variable <code>ActiveInstances</code>. Both functions in multiple goroutines are trying to access the same variable(<code>ActiveInstances</code>) at the same time. Which created race condition. After exploring a few blogs &amp; documentation, I become to know that <strong><em>&ldquo;Maps are not safe for concurrent use&rdquo;</em></strong>.</p>
<p>As per golang doc</p>
<blockquote>
<p>Map access is unsafe only when updates are occurring. As long as all goroutines are only reading—looking up elements in the map, including iterating through it using a for range loop—and not changing the map by assigning to elements or doing deletions, it is safe for them to access the map concurrently without synchronization.</p>
</blockquote>
<h2 id="solution">Solution:</h2>
<p>Here we need to access <code>ActiveInstances</code> synchronously. We want to make sure only one goroutine can access a variable at a time to avoid conflicts, This can be easily achieved by <code>sync.Mutex</code>. This concept is called mutual exclusion which provides methods <code>Lock</code> and <code>Unlock</code>.</p>
<p>We can define a block of code to be executed in mutual exclusion by surrounding it with a call to <code>Lock</code> and <code>Unlock</code>
It is as simple as below:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>var mutex <span style="color:#f92672">=</span> &amp;sync.Mutex<span style="color:#f92672">{}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>mutex.Lock<span style="color:#f92672">()</span>
</span></span><span style="display:flex;"><span>//my block of code
</span></span><span style="display:flex;"><span>mutex.Unlock<span style="color:#f92672">()</span>
</span></span></code></pre></div><h2 id="code-modifications">Code Modifications:</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>var mutex <span style="color:#f92672">=</span> &amp;sync.Mutex<span style="color:#f92672">{}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>mutex.Lock<span style="color:#f92672">()</span>
</span></span><span style="display:flex;"><span>ActiveInstances<span style="color:#f92672">[</span>i_id<span style="color:#f92672">]</span> <span style="color:#f92672">=</span> make<span style="color:#f92672">(</span>chan string, 5<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>mutex.Unlock<span style="color:#f92672">()</span>
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>mutex.Lock<span style="color:#f92672">()</span>
</span></span><span style="display:flex;"><span>delete<span style="color:#f92672">(</span>ActiveInstances, id<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>mutex.Unlock<span style="color:#f92672">()</span>
</span></span></code></pre></div><p>This is how we successfully fix this problem.</p>
<h2 id="code-to-reproduce">Code to Reproduce</h2>
<p>To reproduce, Comment Mutex related all operation like line no. 12, 30, 32, 44, 46. Mutex is use to prevent race condition which generates this error.</p>
<script src="https://gist.github.com/ashishtiwari1993/d494b71ac264184ba46ced1bf2114c30.js"></script>

<h2 id="references">References:</h2>
<p><a href="https://blog.golang.org/go-maps-in-action">https://blog.golang.org/go-maps-in-action</a><br>
<a href="https://golang.org/doc/faq#atomic_maps">https://golang.org/doc/faq#atomic_maps</a><br>
<a href="https://gobyexample.com/mutexes">https://gobyexample.com/mutexes</a></p>
]]></content:encoded>
    </item>
    <item>
      <title>How to scale with massive update queries in Elasticsearch?</title>
      <link>https://ashish.one/talks/scale-with-massive-updates-queries-in-elasticsearch/</link>
      <pubDate>Sun, 08 Dec 2019 20:26:06 +0530</pubDate>
      <guid>https://ashish.one/talks/scale-with-massive-updates-queries-in-elasticsearch/</guid>
      <description>&lt;h1 id=&#34;introduction&#34;&gt;Introduction&lt;/h1&gt;
&lt;h2 id=&#34;what-this-talk-is-all-about&#34;&gt;What this talk is all about?&lt;/h2&gt;
&lt;p&gt;We recently moved from MySQL to Elasticsearch where we got a direct 10x - 15x boost in our performance.&lt;/p&gt;
&lt;p&gt;We came up with unique use cases of heavy updates in Elasticsearch. That been challenging but yes currently Our Elaticsearch handling 200 million requests per day very efficiently. Our WRITE consist of the partial update, update with script conditions and of course simple indexing.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h1 id="introduction">Introduction</h1>
<h2 id="what-this-talk-is-all-about">What this talk is all about?</h2>
<p>We recently moved from MySQL to Elasticsearch where we got a direct 10x - 15x boost in our performance.</p>
<p>We came up with unique use cases of heavy updates in Elasticsearch. That been challenging but yes currently Our Elaticsearch handling 200 million requests per day very efficiently. Our WRITE consist of the partial update, update with script conditions and of course simple indexing.</p>
<p>Our READ request is 1 million/day which contains Scroll, simple search &amp; Aggregations Query. We achieved to display our email logs in next to real-time.
We also worked on Disk optimization by believing in the principle of &ldquo;Know your query&rdquo;. Currently having 6TB + of the cluster with 80 GB ingestion per day.</p>
<h2 id="slides">Slides</h2>
<div id="Container"
 style="padding-bottom:56.25%; position:relative; display:block; width: 100%">
 <iframe id="googleSlideIframe"
  width="100%" height="100%"
  src="https://docs.google.com/presentation/d/e/2PACX-1vRiOzGgkrN1dO7fD4MDUKzr8WIhHqIhS5Iw1N27_mxYVdtPYcK17ib6ZTdg3bgExVuccJ35vxUSNP3X/embed?start=false&amp;loop=false&amp;delayms=3000"
  frameborder="0" allowfullscreen=""
  style="position:absolute; top:0; left: 0"></iframe>
</div>

<h2 id="talk-video">Talk Video</h2>


    
    <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/NSZXMv0va74?autoplay=0&controls=1&end=0&loop=0&mute=0&start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"
      ></iframe>
    </div>

<!-- raw HTML omitted -->
<h4 id="feel-free-to-comment-below-if-you-have-any-doubts-or-suggestion-about-this-talk">Feel free to comment below, If you have any doubts or suggestion about this talk.</h4>
]]></content:encoded>
    </item>
    <item>
      <title>Elasticsearch Exceptions &amp; Challenges</title>
      <link>https://ashish.one/blogs/elasticsearch-exceptions-and-challenges/</link>
      <pubDate>Tue, 03 Dec 2019 02:47:28 +0530</pubDate>
      <guid>https://ashish.one/blogs/elasticsearch-exceptions-and-challenges/</guid>
      <description>&lt;p&gt;Below are some challenges &amp;amp; exceptions faced while setting up Elasticsearch. I just shared my experience and learning. Please correct me, If you guys feel somewhere i got wrong OR You can contribute if you have any experiences . Will keep update this gist.&lt;/p&gt;
&lt;p&gt;&lt;script src=&#34;https://gist.github.com/ashishtiwari1993/004a19f4a44efc214403a7fc1ee27cda.js&#34;&gt;&lt;/script&gt;

Every use case having different solutions. You can try accordingly.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Below are some challenges &amp; exceptions faced while setting up Elasticsearch. I just shared my experience and learning. Please correct me, If you guys feel somewhere i got wrong OR You can contribute if you have any experiences . Will keep update this gist.</p>
<p><script src="https://gist.github.com/ashishtiwari1993/004a19f4a44efc214403a7fc1ee27cda.js"></script>

Every use case having different solutions. You can try accordingly.</p>
]]></content:encoded>
    </item>
    <item>
      <title>How to reset 1-Click Installed WordPress on DigitalOcean?</title>
      <link>https://ashish.one/blogs/how-to-reset-1-click-installed-wordpress-on-digitalocean/</link>
      <pubDate>Tue, 03 Dec 2019 00:49:07 +0530</pubDate>
      <guid>https://ashish.one/blogs/how-to-reset-1-click-installed-wordpress-on-digitalocean/</guid>
      <description>&lt;h2 id=&#34;the-requirement&#34;&gt;The Requirement&lt;/h2&gt;
&lt;p&gt;Need to install fresh wordpress with same version on wordpress droplet of digitalocean.&lt;/p&gt;
&lt;h2 id=&#34;the-problem&#34;&gt;The Problem&lt;/h2&gt;
&lt;p&gt;My setup (wordpress droplet) was suddenly stop working. I started debugging.&lt;/p&gt;
&lt;h2 id=&#34;debug&#34;&gt;Debug&lt;/h2&gt;
&lt;p&gt;Checked &lt;code&gt;apache2&lt;/code&gt; and &lt;code&gt;mysql&lt;/code&gt; service:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;service mysql status
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;service apache2 status
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Both services was active. Then I checked the &lt;code&gt;apache2&lt;/code&gt; processes with below command:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ ps -ef | grep apache2 | wc -l
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;151&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Lots of apache child process has been forked. Which was not good.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h2 id="the-requirement">The Requirement</h2>
<p>Need to install fresh wordpress with same version on wordpress droplet of digitalocean.</p>
<h2 id="the-problem">The Problem</h2>
<p>My setup (wordpress droplet) was suddenly stop working. I started debugging.</p>
<h2 id="debug">Debug</h2>
<p>Checked <code>apache2</code> and <code>mysql</code> service:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>service mysql status
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>service apache2 status
</span></span></code></pre></div><p>Both services was active. Then I checked the <code>apache2</code> processes with below command:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ ps -ef | grep apache2 | wc -l
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">151</span>
</span></span></code></pre></div><p>Lots of apache child process has been forked. Which was not good.</p>
<p>checked apache&rsquo;s error log (<code>tail /var/log/apache2/error.log</code>), But not found anything.</p>
<p>I took decision to setup new wordpress of same version. I was little sure that some plugin was causing this problem But i don&rsquo;t have so much time to go through all plugins.</p>
<h2 id="droplet-configuration">Droplet configuration</h2>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>OS : Ubuntu 18.04.3 LTS
</span></span><span style="display:flex;"><span>Memory : 1GB
</span></span><span style="display:flex;"><span>Disk : 25GB
</span></span><span style="display:flex;"><span>Cost : $5/Monthly
</span></span></code></pre></div><h2 id="process-to-install-wordpress">Process to install WordPress</h2>
<h3 id="step-1-source-directory-backup">Step 1: Source directory backup</h3>
<p>Take backup with <code>cp</code> command.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ cd
</span></span><span style="display:flex;"><span>$ mkdir ~/backup_wp
</span></span><span style="display:flex;"><span>$ cp -R /var/www/html ~/backup_wp/
</span></span></code></pre></div><p>Digitalocean installs the wordpress in <code>/var/www/html/</code> path.</p>
<h3 id="step-2-database-backup">Step 2: Database backup</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ mysqldump -uroot -p wordpress &gt; ~/backup_wp/wp.sql
</span></span></code></pre></div><p>Here <code>wordpress</code> is the Database name.</p>
<p>If you don&rsquo;t remember the password for MySQL, Get it from <code>wp-config.php</code>:</p>
<p><code>vim /var/www/html/wp-config.php</code></p>
<p>Check for the line<br>
<code>define( 'DB_PASSWORD', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' );</code></p>
<h3 id="step-3-check-version-of-the-existing-wordpress">Step 3: Check version of the existing WordPress</h3>
<p><code>vim /var/www/html/wp-includes/version.php</code></p>
<p>Look for the line<br>
<code>$wp_version = '5.2.4';</code></p>
<p>Version can be different.</p>
<h3 id="step-4-download-wordpress-zip-file">Step 4: Download WordPress zip file</h3>
<p>Go to <a href="https://wordpress.org/download/releases/">Wordpress Releases page</a>. Check for your version and download with below command:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>wget https://wordpress.org/wordpress-5.2.4.zip
</span></span></code></pre></div><p>Unzip it:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>unzip wordpress-5.2.4.zip
</span></span></code></pre></div><p>It will extract all files in <code>wordpress</code> folder.</p>
<p>If <code>unzip</code> is not already installed, Please install it with below command:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>apt install unzip
</span></span></code></pre></div><h3 id="step-5-replace-source-of-html-with-wordpress">Step 5: Replace source of <code>/html</code> with <code>/wordpress</code></h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>rm -rf /var/www/html
</span></span><span style="display:flex;"><span>mv wordpress /var/www/html
</span></span></code></pre></div><h3 id="step-6-change-configuration">Step 6: Change configuration</h3>
<ol>
<li>
<p>Go to your website URL, It will show you below page:</p>
<p><img loading="lazy" src="/img/wordpress-digitalocean-reset/lets_go.png" alt="Lets_go"  />
</p>
<p>Just click on the <code>Let's go!</code> Button.</p>
</li>
<li>
<p>Put you DB conf as shown in below image</p>
<p><img loading="lazy" src="/img/wordpress-digitalocean-reset/db_conf.png" alt="db_conf"  />
</p>
<p>Click on the <code>Submit</code> Button.</p>
</li>
<li>
<p>Create <code>wp-config.php</code> file</p>
<p><img loading="lazy" src="/img/wordpress-digitalocean-reset/wp-config.png" alt="wp-config"  />
</p>
<p>Create manually (<code>vim /var/www/html/wp-config.php</code>) if it is not created automatically and click on the <code>Run the installation</code> Button.</p>
</li>
<li>
<p>You will see <code>Already Installed</code> page</p>
<p><img loading="lazy" src="/img/wordpress-digitalocean-reset/already_installed.png" alt="already_installed"  />
</p>
<p>Just click on the <code>Log In</code> button. It will redirect you on the admin panel login page.</p>
</li>
</ol>
<p>Now you can log in into your admin panel.</p>
<h3 id="step-7-copy-important-files-from-backup">Step 7: Copy important files from backup</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cp -R ~/backup_wp/html/wp-content/plugins/ /var/www/html/wp-content/
</span></span><span style="display:flex;"><span>cp -R ~/backup_wp/html/wp-content/themes/ /var/www/html/wp-content/
</span></span><span style="display:flex;"><span>cp -R ~/backup_wp/html/wp-content/uploads/ /var/www/html/wp-content/
</span></span></code></pre></div><p>This will copy all existing plugins, themes &amp; all media files. But be careful while copying it, Becuase if it is the cause of your bug it can bring your site down again.</p>
<p><strong>Important Configuration</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>cp ~/backup_wp/html/.htaccess /var/www/html/
</span></span></code></pre></div><p>Otherwise, your URL routing won&rsquo;t work.</p>
<h3 id="step-8-wordpress-asking-for-ftp-details">Step 8: WordPress asking for FTP details</h3>
<p>If WordPress asking for FTP details on the each option like Adding themes, Installing plugins etc. Then add below line in your <code>wp-config.php</code> file.</p>
<p><code>vim /var/www/html/wp-config.php</code></p>
<p>Add</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>define<span style="color:#f92672">(</span><span style="color:#e6db74">&#39;FS_METHOD&#39;</span>,<span style="color:#e6db74">&#39;direct&#39;</span><span style="color:#f92672">)</span>;
</span></span></code></pre></div><h2 id="test-complete-website">Test complete website</h2>
<p>If everything went perfect, It will run smoothly. So we have successfully set up new Vanilla WordPress with exisiting database and without touching to apache configurations. If you feel any doubt or problem feel free to comment below and Also you can share your review in comments.</p>
]]></content:encoded>
    </item>
    <item>
      <title>[Part 3] How to write custom prometheus exporter?</title>
      <link>https://ashish.one/blogs/write-custom-exporters-prometheus/</link>
      <pubDate>Fri, 29 Nov 2019 22:51:27 +0530</pubDate>
      <guid>https://ashish.one/blogs/write-custom-exporters-prometheus/</guid>
      <description>&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In &lt;a href=&#34;https://ashish.one/blogs/setup-prometheus-and-exporters/&#34;&gt;PART-1&lt;/a&gt; and &lt;a href=&#34;https://ashish.one/blogs/setup-alertmanager/&#34;&gt;PART-2&lt;/a&gt;, We have seen how prometheus works and how to setup Prometheus and exporters. We have readymade exporters available on the internet.&lt;/p&gt;
&lt;p&gt;But sometime there is situation where you need to store your own custom metrics on prometheus. In such case you have to write your own exporters which will exporters the data into Prometheus.&lt;/p&gt;
&lt;h2 id=&#34;there-is-two-way-to-exporting-the-data-on-prometheus&#34;&gt;There is two way to exporting the data on prometheus:&lt;/h2&gt;
&lt;h3 id=&#34;1-exporting-to-a-pushgateway&#34;&gt;1. Exporting to a Pushgateway&lt;/h3&gt;
&lt;p&gt;Here we metrics are getting the push to prometheus server. It not exposed over any URL or port. Internally it directly calls to Prometheus host and pushes the metrics to that.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h2 id="introduction">Introduction</h2>
<p>In <a href="https://ashish.one/blogs/setup-prometheus-and-exporters/">PART-1</a> and <a href="https://ashish.one/blogs/setup-alertmanager/">PART-2</a>, We have seen how prometheus works and how to setup Prometheus and exporters. We have readymade exporters available on the internet.</p>
<p>But sometime there is situation where you need to store your own custom metrics on prometheus. In such case you have to write your own exporters which will exporters the data into Prometheus.</p>
<h2 id="there-is-two-way-to-exporting-the-data-on-prometheus">There is two way to exporting the data on prometheus:</h2>
<h3 id="1-exporting-to-a-pushgateway">1. Exporting to a Pushgateway</h3>
<p>Here we metrics are getting the push to prometheus server. It not exposed over any URL or port. Internally it directly calls to Prometheus host and pushes the metrics to that.</p>
<h3 id="2-exposing-over-http-on-specific-port">2. Exposing over HTTP (on specific port)</h3>
<p>In this option, Exporter will expose all data over HTTP in prometheus data format. Like below:</p>
<p><img loading="lazy" src="/img/prometheus-setup/node_exporter_metrics.png" alt="Node exporter metrics"  />
</p>
<p>It exposes the data on a specific port e.g <code>http://myurl:8000</code>.</p>
<h2 id="basic-example">Basic Example</h2>
<p>Let&rsquo;s take a very basic example, Suppose there is one script (Daemon service) is running with the name <code>myprocess.go</code>. What do we do in real life to check if some script is running or not? We just hit <code>ps</code> command like below:</p>
<p><code>ps -ef | grep 'myprocess'</code></p>
<p>Now we are going to do the same in our exporter. It will hit the same command and if script is running we will set value <code>1</code> else <code>0</code>.</p>
<h2 id="writing-exporter">Writing Exporter</h2>
<p>We are going to use the Second option (Exposing over HTTP).</p>
<h3 id="step-1">Step 1</h3>
<p>We going to use <a href="https://github.com/prometheus/client_python">python_client</a>. Just install it with below <code>pip</code> command:</p>
<p><code>pip install prometheus_client</code></p>
<h3 id="step-2">Step 2</h3>
<p>We need webserver gateway, For which we are going to use <a href="https://www.python.org/dev/peps/pep-0333/">WSGI</a>.</p>
<h3 id="step-3">Step 3</h3>
<p>Whenever we are writing exporters, We need to take care of metric type storage. Prometheus offered four types of metrics: Counter, Gauge, Summary, and Histogram. You can explore more <a href="https://github.com/prometheus/client_python#instrumenting">here</a>. Decide your metric type before pushing data.</p>
<h3 id="step-4">Step 4</h3>
<p>We are going to run a webserver on <code>8000</code> port and exposing the result on <code>/metrics</code> path. So to access metrics just hit <code>http://myurl.com:8000/metrics</code>.</p>
<h3 id="step-5">Step 5</h3>
<p>Complet sample code from my gist:</p>
<script src="https://gist.github.com/ashishtiwari1993/7fca576c55cce93b8b980cdfcc420744.js"></script>

<h3 id="step-6">Step 6</h3>
<p>Add config in <code>prometheus.yml</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>  - job_name: service_up_exporter
</span></span><span style="display:flex;"><span>    scrape_interval: 2m
</span></span><span style="display:flex;"><span>    scrape_timeout:  2m
</span></span><span style="display:flex;"><span>    metrics_path: <span style="color:#e6db74">&#34;/metrics&#34;</span>
</span></span><span style="display:flex;"><span>    static_configs:
</span></span><span style="display:flex;"><span>    - targets: <span style="color:#f92672">[</span><span style="color:#e6db74">&#39;exporterurl.com:8000/metrics&#39;</span><span style="color:#f92672">]</span>
</span></span></code></pre></div><h3 id="step-7">Step 7</h3>
<p>Restart prometheus service:</p>
<p><code>sudo service prometheus restart</code></p>
<blockquote>
<p>This is just a very basic example. It is a simple script to understand the way of writing exporters. You can write your custom exporters according to your use case.</p>
</blockquote>
<p>Here we have successfully write exporter which will expose the metrics. To know more about pushgateway or HTTP expoorter visit <a href="https://github.com/prometheus/client_python#instrumenting">here</a></p>
<p>In <a href="https://ashish.one/blogs/setup-grafana-with-prometheus/">part - 4</a>, I have explained how you can integrate Grafana with Prometheus.</p>
<p>Share you comments below :)</p>
]]></content:encoded>
    </item>
    <item>
      <title>[Part 2] How to setup alertmanager and send alerts ?</title>
      <link>https://ashish.one/blogs/setup-alertmanager/</link>
      <pubDate>Wed, 23 Oct 2019 15:24:26 +0530</pubDate>
      <guid>https://ashish.one/blogs/setup-alertmanager/</guid>
      <description>&lt;h1 id=&#34;introduction&#34;&gt;Introduction&lt;/h1&gt;
&lt;p&gt;In &lt;a href=&#34;https://ashish.one/blogs/setup-prometheus-and-exporters/&#34;&gt;PART - 1&lt;/a&gt;, We have successfully setup Prometheus and exporters. In this part, we are going to setup alertmanager and will send our first alert.&lt;/p&gt;
&lt;p&gt;Alertmanager is software that is maintained by the prometheus and it is written in Go. It takes care of deduplicating, grouping, and routing them to the correct receiver integration such as email, PagerDuty, or OpsGenie. It also takes care of silencing and inhibition of alerts.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h1 id="introduction">Introduction</h1>
<p>In <a href="https://ashish.one/blogs/setup-prometheus-and-exporters/">PART - 1</a>, We have successfully setup Prometheus and exporters. In this part, we are going to setup alertmanager and will send our first alert.</p>
<p>Alertmanager is software that is maintained by the prometheus and it is written in Go. It takes care of deduplicating, grouping, and routing them to the correct receiver integration such as email, PagerDuty, or OpsGenie. It also takes care of silencing and inhibition of alerts.</p>
<p>Let&rsquo;s setup alertmanage: )</p>
<h1 id="setup-alertmanager">Setup Alertmanager</h1>
<h2 id="installation">Installation:</h2>
<p>Prerequisites will be the same as <a href="https://ashish.one/blogs/setup-prometheus-and-exporters/">PART - 1</a> . We will download the precompiled binary of alertmanager. Although there is a docker image also available which you can use.</p>
<h3 id="step-1-download-alertmanager">Step 1: Download alertmanager</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ wget https://github.com/prometheus/prometheus/releases/download/v2.13.1/prometheus-2.13.1.linux-amd64.tar.gz
</span></span></code></pre></div><p><img loading="lazy" src="/img/alertmanager-setup/download_alertmanager.png" alt="alertmanager binary download"  />
</p>
<h3 id="step-2-extract-tar">Step 2: Extract tar</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ tar -xvzf alertmanager-0.19.0.linux-amd64.tar.gz
</span></span></code></pre></div><h3 id="step-3-folder-structure">Step 3: Folder structure</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ mv alertmanager-0.19.0.linux-amd64 alertmanager
</span></span><span style="display:flex;"><span>$ cd alertmanager/
</span></span><span style="display:flex;"><span>$ ll
</span></span></code></pre></div><p>Folder contains below files:</p>
<p><img loading="lazy" src="/img/alertmanager-setup/folder_structure.png" alt="alertmanager folder structure"  />
</p>
<ul>
<li><code>alertmanager</code>: It is a binary file that is core Daemon of alertmanager.</li>
<li><code>alertmanager.yml</code>: This is config file for alertmanager service.</li>
<li><code>amtool</code>: It is another binary that can be used as a command line utility to manager or silence the alerts on alertmanager.</li>
</ul>
<h3 id="step--4-run-alertmanager">Step  4: Run alertmanager</h3>
<p>Execute binary:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>./alertmanager
</span></span></code></pre></div><p><img loading="lazy" src="/img/alertmanager-setup/execute_alertmanager.png" alt="alertmanager folder structure"  />
</p>
<p>Visit to <code>localhost:9093</code> on your browser:</p>
<p><img loading="lazy" src="/img/alertmanager-setup/alertmanager_web.png" alt="alertmanager web"  />
</p>
<p>Your alertmanager is up :) Like prometheus it is creating folder with the name <code>data</code>. Alertmanager starts storing data in <code>/data</code> folder.</p>
<p>To check alertmanager metrics just visit <code>localhost:9093/metrics</code></p>
<p>My production execution command is</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>~/alertmanager/alertmanager --config.file<span style="color:#f92672">=</span>~/alertmanager/alertmanager.yml --storage.path<span style="color:#f92672">=</span>/var/lib/alertmanager --web.external-url<span style="color:#f92672">=</span>http://myurl.com:9093
</span></span></code></pre></div><ul>
<li><code>--storage.tsdb.path</code> : Specify the path where you want to save prometheus data.</li>
<li><code>--web.external-url</code> : You can use this option if you want to bind your address with your URL.</li>
</ul>
<h3 id="step-5-run-alertmanager-as-service">Step 5: Run alertmanager as service</h3>
<ol>
<li>Create file</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>vim /etc/systemd/system/alertmanager.service
</span></span></code></pre></div><ol start="2">
<li>Paste Below code</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="color:#f92672">[</span>Unit<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>Description<span style="color:#f92672">=</span>AlertManager Server Service
</span></span><span style="display:flex;"><span>Wants<span style="color:#f92672">=</span>network-online.target
</span></span><span style="display:flex;"><span>After<span style="color:#f92672">=</span>network-online.target
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>Service<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>User<span style="color:#f92672">=</span>root
</span></span><span style="display:flex;"><span>Type<span style="color:#f92672">=</span>Simple
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>ExecStart<span style="color:#f92672">=</span>~/alertmanager/alertmanager --config.file<span style="color:#f92672">=</span>~/alertmanager/alertmanager.yml --storage.path<span style="color:#f92672">=</span>/var/lib/alertmanager --web.external-url<span style="color:#f92672">=</span>http://myurl.com:9093
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>Install<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>WantedBy<span style="color:#f92672">=</span>multi-user.target
</span></span></code></pre></div><p>Save and exit.</p>
<p>It won’t run because <code>alertmanager.yml</code> is not defined yet. <code>alertmanager.yml</code> file is defined below.</p>
<ol start="3">
<li>Reload the Systemctl Daemon:</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo systemctl daemon-reload
</span></span></code></pre></div><ol start="4">
<li>To start alertmanager service</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo systemctl start alertmanager
</span></span></code></pre></div><h2 id="setup-alerts">Setup Alerts</h2>
<h3 id="step-1-add-settings-in-prometheusyml">Step 1: Add settings in <code>prometheus.yml</code></h3>
<p>Open <code>prometheus.yml</code> file</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ vim ~/prometheus/prometheus.yml
</span></span></code></pre></div><p>Add below code</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>scrape_configs:
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># The job name is added as a label `job=&lt;job_name&gt;` to any timeseries scraped from this config.</span>
</span></span><span style="display:flex;"><span>  - job_name: <span style="color:#e6db74">&#39;prometheus&#39;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># metrics_path defaults to &#39;/metrics&#39;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># scheme defaults to &#39;http&#39;.</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    static_configs:
</span></span><span style="display:flex;"><span>    - targets: <span style="color:#f92672">[</span><span style="color:#e6db74">&#39;localhost:9090&#39;</span><span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># Add below block for node_exporter</span>
</span></span><span style="display:flex;"><span>  - job_name: node_exporter
</span></span><span style="display:flex;"><span>    scrape_interval: 1m
</span></span><span style="display:flex;"><span>    scrape_timeout:  1m
</span></span><span style="display:flex;"><span>    metrics_path: <span style="color:#e6db74">&#34;/metrics&#34;</span>
</span></span><span style="display:flex;"><span>    static_configs:
</span></span><span style="display:flex;"><span>    - targets: <span style="color:#f92672">[</span><span style="color:#e6db74">&#39;localhost:9100&#39;</span><span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">#Alertmanager settings</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>rule_files:
</span></span><span style="display:flex;"><span>  - <span style="color:#e6db74">&#39;~/prometheus/alert.rules.yml&#39;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>alerting:
</span></span><span style="display:flex;"><span>  alertmanagers:
</span></span><span style="display:flex;"><span>  - static_configs:
</span></span><span style="display:flex;"><span>    - targets:
</span></span><span style="display:flex;"><span>      - <span style="color:#e6db74">&#39;myurl.com:9093&#39;</span>
</span></span></code></pre></div><ul>
<li>
<p><code>rule_files</code>: These are the files that contain all kinds of rules. Prometheus has own syntax to define rules. We will see this below.</p>
</li>
<li>
<p><code>alerting</code>: This is an option where we have to define alertmanager configuration. In target, we have defined <code>myurl.com:9093</code> this is the exact port where our alertmanager is running.</p>
</li>
</ul>
<h3 id="step-2-how-prometheus-service-will-work">Step 2: How prometheus service will work?</h3>
<p>In above <code>scrape_config</code> we have defined scrape configurations. In the above example, prometheus will scrape <code>node_exporter</code> job at every 1 minute (scrape_interval is 1m. it will scrape all information which is available on <code>localhost:9100/metrics</code> (It will scrape all targets which is defined in the <code>targets</code> array).</p>
<p>It will store the data in the Internal database.</p>
<p>At every scraping, it will keep evaluating alert rules which defined in <code>alert.rules.yml</code>. As soon as any alert rules get true it will send an event to alertmanager on <code>myurl.com:9093</code></p>
<p>Once alertmanager received events, It will check by which channel alert needs to be trigger like via slack, email pagerduty, etc which defined in <code>alertmanager.yml</code> &amp; it will trigger an alert via appropriate channel. Now let’s define two files :</p>
<ol>
<li><code>alert.rules.yml</code></li>
<li><code>alertmanager.yml</code></li>
</ol>
<h3 id="step-3-create-alertrulesyml">Step 3: Create <code>alert.rules.yml</code></h3>
<p>Create <code>~/prometheus/alert.rules.yml</code> file and paste below sample rule:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>groups:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>- name: Disk-usage
</span></span><span style="display:flex;"><span>  rules:
</span></span><span style="display:flex;"><span>  - alert: <span style="color:#e6db74">&#39;Low data disk space&#39;</span>
</span></span><span style="display:flex;"><span>    expr: ceil<span style="color:#f92672">(((</span>node_filesystem_size_bytes<span style="color:#f92672">{</span>mountpoint!<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;/boot&#34;</span><span style="color:#f92672">}</span> - node_filesystem_free_bytes<span style="color:#f92672">{</span>mountpoint!<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;/boot&#34;</span><span style="color:#f92672">})</span> / node_filesystem_size_bytes<span style="color:#f92672">{</span>mountpoint!<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;/boot&#34;</span><span style="color:#f92672">}</span> * 100<span style="color:#f92672">))</span> &gt; <span style="color:#ae81ff">95</span>
</span></span><span style="display:flex;"><span>    labels:
</span></span><span style="display:flex;"><span>      severity: <span style="color:#e6db74">&#39;critical&#39;</span>
</span></span><span style="display:flex;"><span>    annotations:
</span></span><span style="display:flex;"><span>      title: <span style="color:#e6db74">&#34;Disk Usage&#34;</span>
</span></span><span style="display:flex;"><span>      description: <span style="color:#e6db74">&#39;Partition : {{$labels.mountpoint}}&#39;</span>
</span></span><span style="display:flex;"><span>      summary: <span style="color:#e6db74">&#34;Disk usage is `{{humanize </span>$value<span style="color:#e6db74">}}%`&#34;</span>
</span></span><span style="display:flex;"><span>      host: <span style="color:#e6db74">&#34;{{</span>$labels<span style="color:#e6db74">.instance}}&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>- name: Memory-usage
</span></span><span style="display:flex;"><span>  rules:
</span></span><span style="display:flex;"><span>  - alert: <span style="color:#e6db74">&#39;High memory usage&#39;</span>
</span></span><span style="display:flex;"><span>    expr: ceil<span style="color:#f92672">((((</span>node_memory_MemTotal_bytes - node_memory_MemFree_bytes - node_memory_Buffers_bytes - node_memory_Cached_bytes<span style="color:#f92672">)</span> / node_memory_MemTotal_bytes<span style="color:#f92672">)</span> * 100<span style="color:#f92672">))</span> &gt; <span style="color:#ae81ff">80</span>
</span></span><span style="display:flex;"><span>    labels:
</span></span><span style="display:flex;"><span>      severity: <span style="color:#e6db74">&#39;critical&#39;</span>
</span></span><span style="display:flex;"><span>    annotations:
</span></span><span style="display:flex;"><span>      title: <span style="color:#e6db74">&#34;Memory Usage&#34;</span>
</span></span><span style="display:flex;"><span>      description: <span style="color:#e6db74">&#39;Memory usage threshold set to `80%`.&#39;</span>
</span></span><span style="display:flex;"><span>      summary: <span style="color:#e6db74">&#34;Memory usage is `{{humanize </span>$value<span style="color:#e6db74">}}%`&#34;</span>
</span></span><span style="display:flex;"><span>      host: <span style="color:#e6db74">&#34;{{</span>$labels<span style="color:#e6db74">.instance}}&#34;</span>
</span></span></code></pre></div><p>Here we have defined two rules.</p>
<ol>
<li>If memory utilization is exceeded than 80% then it will trigger an email.</li>
<li>If any disk partition usage exceeded than 95% then it will trigger an email.</li>
</ol>
<p>You will get more insights on defining alerting rules <a href="https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/">here</a>.</p>
<p>Now you might be wondering what is <code>node_filesystem_size_bytes</code> or <code>node_memory_MemTotal_bytes</code> ?</p>
<p>If we recall part - 1 when we set up the node exporter and visited on <code>localhost:9100/metrics</code>, It has shown some metric. In that will get the above variable name. If you want to put any alert rules irrespective of any exporters, You have to make <code>expr</code> using these variables.</p>
<p>You can compile your alert rule file :</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ promtool check rules alert.rules.yml
</span></span></code></pre></div><p><code>promtool</code> is binary which we got in prometheus folder when we extracted it.</p>
<p>You can explore some sample rules <a href="https://awesome-prometheus-alerts.grep.to/rules.html">here</a>.</p>
<h3 id="step-4-create-alertmanageryml">Step 4: Create alertmanager.yml</h3>
<p>Create <code>~/alertmanager/alertmanager.yml</code> file and paste below code:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>global:
</span></span><span style="display:flex;"><span>  slack_api_url: <span style="color:#e6db74">&#34;https://hooks.slack.com/services/XXXXXXXXXXXXXXX&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>route:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  receiver: <span style="color:#e6db74">&#34;default&#34;</span>
</span></span><span style="display:flex;"><span>  routes:
</span></span><span style="display:flex;"><span>   - match:
</span></span><span style="display:flex;"><span>      severity: info
</span></span><span style="display:flex;"><span>     receiver: slack
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>   - match:
</span></span><span style="display:flex;"><span>      severity: critical
</span></span><span style="display:flex;"><span>     receiver: email
</span></span><span style="display:flex;"><span>     group_wait: 30s
</span></span><span style="display:flex;"><span>     group_interval: 5m
</span></span><span style="display:flex;"><span>     repeat_interval: 5m
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>receivers:
</span></span><span style="display:flex;"><span>  - name: default
</span></span><span style="display:flex;"><span>    email_configs:
</span></span><span style="display:flex;"><span>     - to: <span style="color:#e6db74">&#39;to@youremail.com&#39;</span>
</span></span><span style="display:flex;"><span>       from: <span style="color:#e6db74">&#39;default-alerts@yourdomain.com&#39;</span>
</span></span><span style="display:flex;"><span>       smarthost: <span style="color:#e6db74">&#39;smtp.host.com:2525&#39;</span>
</span></span><span style="display:flex;"><span>       auth_username: <span style="color:#e6db74">&#34;smtpusername&#34;</span>
</span></span><span style="display:flex;"><span>       auth_password: <span style="color:#e6db74">&#34;smtppassword&#34;</span>
</span></span><span style="display:flex;"><span>       html: <span style="color:#e6db74">&#39;{{ template &#34;email&#34; .}}&#39;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  - name: slack
</span></span><span style="display:flex;"><span>    slack_configs:
</span></span><span style="display:flex;"><span>      - send_resolved: true
</span></span><span style="display:flex;"><span>        username: <span style="color:#e6db74">&#39;{{ template &#34;slack.default.username&#34; . }}&#39;</span>
</span></span><span style="display:flex;"><span>        color: <span style="color:#e6db74">&#39;{{ if eq .Status &#34;firing&#34; }}good{{ else }}good{{ end }}&#39;</span>
</span></span><span style="display:flex;"><span>        title: <span style="color:#e6db74">&#39;{{ template &#34;slack.default.title&#34; . }}&#39;</span>
</span></span><span style="display:flex;"><span>        title_link: <span style="color:#e6db74">&#39;{{ template &#34;slack.default.titlelink&#34; . }}&#39;</span>
</span></span><span style="display:flex;"><span>        pretext: <span style="color:#e6db74">&#39;{{ .CommonAnnotations.summary }}&#39;</span>
</span></span><span style="display:flex;"><span>        text:
</span></span><span style="display:flex;"><span>         &gt;-
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">{{</span> range .Alerts <span style="color:#f92672">}}</span>
</span></span><span style="display:flex;"><span>           *Alert:* <span style="color:#f92672">{{</span> .Annotations.summary <span style="color:#f92672">}}</span> - <span style="color:#e6db74">`</span><span style="color:#f92672">{{</span> .Labels.severity <span style="color:#f92672">}}</span><span style="color:#e6db74">`</span>:bar_chart:
</span></span><span style="display:flex;"><span>           *Description:* <span style="color:#f92672">{{</span> .Annotations.description <span style="color:#f92672">}}</span>
</span></span><span style="display:flex;"><span>           *Details:*
</span></span><span style="display:flex;"><span>           <span style="color:#f92672">{{</span> range .Labels.SortedPairs <span style="color:#f92672">}}</span> • *<span style="color:#f92672">{{</span> .Name <span style="color:#f92672">}}</span>:* <span style="color:#e6db74">`</span><span style="color:#f92672">{{</span> .Value <span style="color:#f92672">}}</span><span style="color:#e6db74">`</span>
</span></span><span style="display:flex;"><span>           <span style="color:#f92672">{{</span> end <span style="color:#f92672">}}</span>
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">{{</span> end <span style="color:#f92672">}}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  - name: email
</span></span><span style="display:flex;"><span>    email_configs:
</span></span><span style="display:flex;"><span>     - to: <span style="color:#e6db74">&#39;to@youremail.com&#39;</span>
</span></span><span style="display:flex;"><span>       from: <span style="color:#e6db74">&#39;default-alerts@yourdomain.com&#39;</span>
</span></span><span style="display:flex;"><span>       smarthost: <span style="color:#e6db74">&#39;smtp.host.com:2525&#39;</span>
</span></span><span style="display:flex;"><span>       auth_username: <span style="color:#e6db74">&#34;smtpusername&#34;</span>
</span></span><span style="display:flex;"><span>       auth_password: <span style="color:#e6db74">&#34;smtppassword&#34;</span>
</span></span><span style="display:flex;"><span>       html: <span style="color:#e6db74">&#39;{{ template &#34;email&#34; .}}&#39;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>templates:
</span></span><span style="display:flex;"><span>- <span style="color:#e6db74">&#39;~/prometheus/alert.tmpl&#39;</span>
</span></span></code></pre></div><p>Here we have setup two channel email and slack for alert. if you see <code>alertmanager.yml</code> file, There are four main components I defined.</p>
<ul>
<li><code>global</code>: Here we can define any global variable like we defined <code>slack_api_url</code>.</li>
<li><code>route</code>: It is a routing block. I am playing routing on <code>severity</code>. Similarly, it is your choice on which variable you want to route your alerts. So here if <code>severity == ‘info’</code>, Alert will go from slack or if <code>severity == ‘critical’</code>, Alert will go via an email.</li>
<li><code>receivers</code>: Here we can define the channel by which alert will go. For now, I have defined only email &amp; slack. You can explore more receivers <a href="https://prometheus.io/docs/alerting/configuration/#receiver">here</a>.</li>
<li><code>templates</code>: It is an alert template where I have defined the HTML template for an email alert. It is not restricted to email. You can define a template for any channel. Explore more details about templates <a href="https://prometheus.io/docs/alerting/notification_examples/">here</a>.</li>
</ul>
<h3 id="step-5-sample-template">Step 5: Sample template</h3>
<p>Create and Paste below code in <code>~/prometheus/alert.tmpl</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="color:#f92672">{{</span> define <span style="color:#e6db74">&#34;email&#34;</span> <span style="color:#f92672">}}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>&lt;html&gt;
</span></span><span style="display:flex;"><span>   &lt;head&gt;
</span></span><span style="display:flex;"><span>      &lt;style type<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;text/css&#34;</span>&gt;
</span></span><span style="display:flex;"><span>         table <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>         font-family: verdana,arial,sans-serif;
</span></span><span style="display:flex;"><span>         font-size:11px;
</span></span><span style="display:flex;"><span>         color:#333333;
</span></span><span style="display:flex;"><span>         border-width: 1px;
</span></span><span style="display:flex;"><span>         border-color: <span style="color:#75715e">#999999;</span>
</span></span><span style="display:flex;"><span>         border-collapse: collapse;
</span></span><span style="display:flex;"><span>         <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>         table th <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>         background-color:#ff6961;
</span></span><span style="display:flex;"><span>         border-width: 1px;
</span></span><span style="display:flex;"><span>         padding: 8px;
</span></span><span style="display:flex;"><span>         border-style: solid;
</span></span><span style="display:flex;"><span>         border-color: <span style="color:#75715e">#F54C44;</span>
</span></span><span style="display:flex;"><span>         <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>         table td <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>         border-width: 1px;
</span></span><span style="display:flex;"><span>         padding: 8px;
</span></span><span style="display:flex;"><span>         border-style: solid;
</span></span><span style="display:flex;"><span>         border-color: <span style="color:#75715e">#F54C44;</span>
</span></span><span style="display:flex;"><span>         text-align: right;
</span></span><span style="display:flex;"><span>         <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>      &lt;/style&gt;
</span></span><span style="display:flex;"><span>   &lt;/head&gt;
</span></span><span style="display:flex;"><span>   &lt;body&gt;
</span></span><span style="display:flex;"><span>      &lt;table border<span style="color:#f92672">=</span>1&gt;
</span></span><span style="display:flex;"><span>         &lt;thead&gt;    
</span></span><span style="display:flex;"><span>           &lt;tr&gt;
</span></span><span style="display:flex;"><span>        &lt;th&gt;Alert name&lt;/th&gt;
</span></span><span style="display:flex;"><span>        &lt;th&gt;Host&lt;/th&gt;
</span></span><span style="display:flex;"><span>            &lt;th&gt;Summary&lt;/th&gt;
</span></span><span style="display:flex;"><span>            &lt;th&gt;Description&lt;/th&gt;
</span></span><span style="display:flex;"><span>           &lt;/tr&gt;
</span></span><span style="display:flex;"><span>         &lt;/thead&gt;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>         &lt;tbody&gt;
</span></span><span style="display:flex;"><span>       <span style="color:#f92672">{{</span> range .Alerts <span style="color:#f92672">}}</span>
</span></span><span style="display:flex;"><span>            &lt;tr&gt;
</span></span><span style="display:flex;"><span>         &lt;td&gt;<span style="color:#f92672">{{</span> .Labels.alertname <span style="color:#f92672">}}</span>&lt;/td&gt;
</span></span><span style="display:flex;"><span>         &lt;td&gt;<span style="color:#f92672">{{</span> .Annotations.host <span style="color:#f92672">}}</span>&lt;/td&gt;
</span></span><span style="display:flex;"><span>         &lt;td&gt;<span style="color:#f92672">{{</span> .Annotations.summary <span style="color:#f92672">}}</span>&lt;/td&gt;
</span></span><span style="display:flex;"><span>         &lt;td&gt;<span style="color:#f92672">{{</span> .Annotations.description <span style="color:#f92672">}}</span>&lt;/td&gt;
</span></span><span style="display:flex;"><span>           &lt;/tr&gt;
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">{{</span> end <span style="color:#f92672">}}</span>
</span></span><span style="display:flex;"><span>         &lt;/tbody&gt;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      &lt;/table&gt;
</span></span><span style="display:flex;"><span>  &lt;/body&gt;
</span></span><span style="display:flex;"><span>&lt;/html&gt;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{{</span>end<span style="color:#f92672">}}</span>
</span></span></code></pre></div><h3 id="step-6-start-alertmanager-service--restart-prometheus">Step 6: Start alertmanager service &amp; restart prometheus</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo systemctl start alertmanager
</span></span><span style="display:flex;"><span>$ sudo systemctl restart prometheus
</span></span></code></pre></div><h2 id="test-complete-integration">Test complete Integration:</h2>
<p>If everything is set up correctly and alert rule getting true then it will trigger an alert. You can enable the log of alertmanager for debugging purposes.</p>
<p>If you want to test alert, Then simply make threshold to very less 0% or 1% after 30s it should trigger the alert.</p>
<p>Visit <code>localhost:9093</code>. If there is some alert you will get the list on the dashboard.</p>
<p>So we successfully setup alert using alertmanager. In <a href="https://ashish.one/blogs/write-custom-exporters-prometheus/">part - 3</a> I have explained how you can write your own custom exporters &amp; You can check <a href="https://ashish.one/blogs/setup-grafana-with-prometheus/">part - 4</a> to integrate Grafana with Prometheus.</p>
]]></content:encoded>
    </item>
    <item>
      <title>[Part 1] How To Setup Prometheus And Exporters For Alerts And Monitoring?</title>
      <link>https://ashish.one/blogs/setup-prometheus-and-exporters/</link>
      <pubDate>Sun, 22 Sep 2019 15:20:39 +0530</pubDate>
      <guid>https://ashish.one/blogs/setup-prometheus-and-exporters/</guid>
      <description>&lt;p&gt;As a developer, many times you would have worried, whether your services are up and running or not. Not only that, sometimes as an infrastructure guy you might be also worried about your server’s health too. What is the current RAM or disk utilization? or whether they are going to be fully occupied which in turn can completely bring the system down. These are just the basics and in fact there are tons of more such things which need to be monitored and fixed in everyday&amp;rsquo;s life.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>As a developer, many times you would have worried, whether your services are up and running or not. Not only that, sometimes as an infrastructure guy you might be also worried about your server’s health too. What is the current RAM or disk utilization? or whether they are going to be fully occupied which in turn can completely bring the system down. These are just the basics and in fact there are tons of more such things which need to be monitored and fixed in everyday&rsquo;s life.</p>
<blockquote>
<p><strong>“Never send a human to do a machine&rsquo;s job”</strong></p>
</blockquote>
<p>At some time, deploying humans to check all these and that too for 24 * 7 can be a real pain.</p>
<p>That&rsquo;s exactly the purpose of writing this tutorial series around monitoring and alerting. In this tutorial, you will learn how to setup Prometheus as a universal monitoring system and how to use its exporter to define and fetch the metrics which are really important to track.</p>
<h2 id="what-is-prometheus">What is Prometheus?</h2>
<p>Prometheus is an open-source system for monitoring and alerting. It developed in the GO language. It is currently a standalone open source project and maintained independently by any organization. You can check more details <a href="https://prometheus.io/docs/introduction/overview/#what-is-prometheus">here</a>.</p>
<h2 id="why-prometheus">Why Prometheus?</h2>
<ol>
<li>Open-source and of course freely available :)</li>
<li>It is constantly contributed by the community. It is stable and used by many good brands.  Check <a href="https://stackshare.io/prometheus">Stackshare</a>.</li>
<li>Good community support and well documented.</li>
<li>You do not need any big infrastructure to get started. It can be started with 1 GB RAM.</li>
<li>It has its own UI to check any metrics. But, many prefer Grafana with Prometheus which gives you better visualization on your Prometheus metrics.</li>
<li>Lots of pre-build Grafana dashboard and exporters already written. You have to just reuse those exporters.
You can check the list of Prometheus features <a href="https://prometheus.io/docs/introduction/overview/#features">here</a>.</li>
<li>You can check the list of Prometheus features <a href="https://prometheus.io/docs/introduction/overview/#features">here</a>.</li>
</ol>
<h2 id="prerequisites-for-setting-up-prometheus">Prerequisites for setting up Prometheus</h2>
<p>Here Is This Tutorial, Prometheus Is Installed And Tested On A Test Server With Minimum Configuration:</p>
<ul>
<li>2 GB RAM</li>
<li>10 GB Avg local disk storage.</li>
<li>GOLANG (go1.11.5 linux/amd64)</li>
<li>Centos7 RHEL</li>
</ul>
<h2 id="setup-prometheus">Setup Prometheus</h2>
<h3 id="installation">Installation</h3>
<p>There are multiple ways to install Prometheus. You can use docker image or use any of the available configuration management systems like Ansible, chef, puppet and salt stack. For more information on installation, visit the official installation guide here.</p>
<p>It also has pre-compiled binaries available. I am going to use this binary for installation because it is easy to set up and easy to understand because of we already familiar with the utilization of binary files.</p>
<h4 id="step-1-download-the-prometheus-binary">Step 1: Download the Prometheus binary</h4>
<p>Visit <a href="https://prometheus.io/download/">Prometheus</a> download page. It will give you a list of pre-compiled binaries for drawins, linux, and windows. You can download according to your OS. Below, the installation is explained for Linux OS.</p>
<p>OR</p>
<p>You can simply fire below command in your Linux terminal:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ wget https://github.com/prometheus/prometheus/releases/download/v2.11.1/prometheus-2.11.1.linux-amd64.tar.gz
</span></span></code></pre></div><p><img loading="lazy" src="/img/prometheus-setup/download_prometheus_binary.png" alt="prometheus binary download"  />
</p>
<h4 id="step-2-extract-the-tar">Step 2: Extract The Tar</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ tar -xvzf prometheus-2.11.1.linux-amd64.tar.gz
</span></span></code></pre></div><h4 id="step-3-after-extraction-steps">Step 3: After Extraction Steps</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ mv prometheus-2.11.1.linux-amd64 prometheus 
</span></span><span style="display:flex;"><span>$ cd prometheus/$ ll
</span></span></code></pre></div><p>Folder contains below file:</p>
<p><img loading="lazy" src="/img/prometheus-setup/folder_structure.png" alt="Folder structure"  />
</p>
<ul>
<li><code>prometheus</code>: It&rsquo;s a binary file which is the core daemon.</li>
<li><code>prometheus.yml</code>: This is the config file for Prometheus service.</li>
<li><code>promtool</code>: This is another binary file which is used to compile the alert rules file. This will be explained in detail in the next series to this tutorial.</li>
</ul>
<h4 id="step-4-execute-the-binary-file-using-the-below-command">Step 4: Execute The Binary File Using The Below Command:</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ ./prometheus
</span></span></code></pre></div><p><img loading="lazy" src="/img/prometheus-setup/start_prometheus.png" alt="Start Prometheus"  />
</p>
<p>Visit <code>localhost:9090</code> on your web browser:</p>
<p><img loading="lazy" src="/img/prometheus-setup/prometheus_ui.png" alt="Prometheus UI"  />
</p>
<p>Your Prometheus is up and running!</p>
<p>If you notice in <code>prometheus/</code> folder, It created a folder with the name <code>data</code>. Prometheus starts storing metrics in this <code>/data</code> folder only.</p>
<p>Now get all metric list by hitting the URL to <code>localhost:9090/metrics</code></p>
<p><img loading="lazy" src="/img/prometheus-setup/metrics.png" alt="Prometheus metrics"  />
</p>
<p>Prometheus stores data on disk in time series, with its custom format.  Behind the scenes, it uses <a href="https://github.com/google/leveldb">leveldb</a>. You can check more <a href="https://prometheus.io/docs/prometheus/latest/storage/">details</a> on storage.</p>
<p>Here is a sample production command:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ ~/prometheus/prometheus --storage.tsdb.path<span style="color:#f92672">=</span>/var/lib/prometheus/data/ --web.external-url<span style="color:#f92672">=</span>http://myurl.com:9090
</span></span></code></pre></div><p><code>--storage.tsdb.path</code>: Specify the path where you want to save Prometheus data.<br>
<code>--web.external-url</code>: You can use this option if you want to bind your address with your URL.</p>
<p>You can get below error in case of your folder don’t have appropriate permission:</p>
<p><code>level=error ts=2019-08-06T14:25:19.791Z caller=main.go:731 err=&quot;opening storage failed: lock DB directory: open /var/lib/lock: permission denied&quot;</code></p>
<p>You can try appending <code>sudo</code>  to your command  OR you can give appropriate permission to your folder.</p>
<h4 id="step-5-run-prometheus-as-service">Step 5: Run Prometheus As Service.</h4>
<ol>
<li>Create File</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ vim /etc/systemd/system/prometheus.service
</span></span></code></pre></div><ol start="2">
<li>Just paste below code:</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="color:#f92672">[</span>Unit<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>Description<span style="color:#f92672">=</span>Prometheus Server
</span></span><span style="display:flex;"><span>Documentation<span style="color:#f92672">=</span>https://prometheus.io/docs/introduction/overview/
</span></span><span style="display:flex;"><span>After<span style="color:#f92672">=</span>network-online.target
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>Service<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>User<span style="color:#f92672">=</span>root
</span></span><span style="display:flex;"><span>Restart<span style="color:#f92672">=</span>on-failure
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">#Change this line if you download the </span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">#Prometheus on different path user</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>ExecStart<span style="color:#f92672">=</span>~/prometheus/prometheus --storage.tsdb.path<span style="color:#f92672">=</span>/var/lib/prometheus/data/ --web.external-url<span style="color:#f92672">=</span>http://myurl.com:9090
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>Install<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>WantedBy<span style="color:#f92672">=</span>multi-user.target
</span></span></code></pre></div><pre><code>Save and exit.
</code></pre>
<ol start="3">
<li>Reload the Systemctl Daemon:</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ sudo systemctl daemon-reload
</span></span></code></pre></div><ol start="4">
<li>Start the Prometheus service:</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>sudo systemctl start prometheus
</span></span></code></pre></div><p>Till now you learned how to do basic Prometheus setup. Now, you will learn, how to set up Prometheus exporter.</p>
<h2 id="prometheus-exporter-setup">Prometheus Exporter Setup</h2>
<h3 id="what-is-exporter">What Is Exporter?</h3>
<p>Exporters can be any scripts or services which will fetch specific metrics from your system and gives data in Prometheus format. There are primarily two ways by which you can fetch metrics and store into Prometheus:</p>
<ol>
<li>
<p>Via exporter, In which one service will run on a specific port. So whenever Prometheus service will hit exporter URL with the specific port it will give output in Prometheus format. We will see sample response in the below example during setting up the node exporter.</p>
</li>
<li>
<p>The second approach is you can write a script which will push data in time series to the Prometheus server. Any metric which cannot be scrape by the exporter, It can be pushed using the push method. You will get more info here on this.</p>
</li>
</ol>
<p>You can use both methods but usually, people prefer the first one to fetch metrics.</p>
<p>So now we are going to setup <a href="https://github.com/prometheus/node_exporter">node exporter</a>. It will fetch your server metrics which will be RAM/DISK/CPU utilization, network, io etc.</p>
<h3 id="node-exporter-setup">Node Exporter Setup</h3>
<h4 id="step-1-download-the-binary-file-and-start-node-exporter">Step 1: Download The Binary File And Start Node Exporter:</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>$ wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
</span></span><span style="display:flex;"><span>$ tar -xvzf node_exporter-0.18.1.linux-amd64.tar.gz
</span></span><span style="display:flex;"><span>$ mv node_exporter-0.18.1.linux-amd64 node_exporter
</span></span><span style="display:flex;"><span>$ cd node_exporter
</span></span><span style="display:flex;"><span>$ ./node_exporter
</span></span></code></pre></div><p>You should see below output once the node exporter is started:</p>
<p><img loading="lazy" src="/img/prometheus-setup/node_exporter_start.png" alt="Start node exporter"  />
</p>
<p>Just visit to <code>localhost:9100/metrics</code></p>
<p><img loading="lazy" src="/img/prometheus-setup/node_exporter_metrics.png" alt="Node exporter metrics"  />
</p>
<h4 id="step-2-lets-run-node-exporter-as-service">Step 2: Let&rsquo;s Run Node Exporter As Service:</h4>
<ol>
<li>Create a file in below path:</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>/etc/systemd/system/node-exporter.service
</span></span></code></pre></div><ol start="2">
<li>Just paste below code:</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="color:#f92672">[</span>Unit<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>Description<span style="color:#f92672">=</span>Node exporter
</span></span><span style="display:flex;"><span>After<span style="color:#f92672">=</span>network-online.target
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>Service<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>User<span style="color:#f92672">=</span>root
</span></span><span style="display:flex;"><span>Restart<span style="color:#f92672">=</span>on-failure
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">#Change this line if you download the </span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">#Prometheus on different path user</span>
</span></span><span style="display:flex;"><span>ExecStart<span style="color:#f92672">=</span>~/node_exporter/node_exporter
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>Install<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>WantedBy<span style="color:#f92672">=</span>multi-user.target
</span></span></code></pre></div><ol start="3">
<li>Reload the systemctl daemon:</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>sudo systemctl daemon-reload
</span></span></code></pre></div><ol start="4">
<li>Start the Prometheus service:</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>sudo systemctl start node-exporter
</span></span></code></pre></div><h4 id="step-3-prometheusyml">Step 3: <code>prometheus.yml</code></h4>
<p>You Are Set With Node Exporter. Now In Prometheus, We Need To Configure This Node Exporter Reference So That Prometheus Can Collect Metrics From This Exporter.</p>
<p>Open file <code>~/prometheus/prometheus.yml</code> add below configuration:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>scrape_configs:
</span></span><span style="display:flex;"><span> <span style="color:#75715e"># The job name is added as a label `job=&lt;job_name&gt;` to any timeseries scraped from this config.</span>
</span></span><span style="display:flex;"><span> - job_name: <span style="color:#e6db74">&#39;prometheus&#39;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># metrics_path defaults to &#39;/metrics&#39;</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># scheme defaults to &#39;http&#39;. </span>
</span></span><span style="display:flex;"><span>   static_configs:
</span></span><span style="display:flex;"><span>   - targets: <span style="color:#f92672">[</span><span style="color:#e6db74">&#39;localhost:9090&#39;</span><span style="color:#f92672">]</span> 
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Add below block for node_exporter</span>
</span></span><span style="display:flex;"><span> - job_name: node_exporter
</span></span><span style="display:flex;"><span>   scrape_interval: 1m
</span></span><span style="display:flex;"><span>   scrape_timeout:  1m
</span></span><span style="display:flex;"><span>   metrics_path: <span style="color:#e6db74">&#34;/metrics&#34;</span> 
</span></span><span style="display:flex;"><span>   static_configs: 
</span></span><span style="display:flex;"><span>   - targets: <span style="color:#f92672">[</span><span style="color:#e6db74">&#39;localhost:9100&#39;</span><span style="color:#f92672">]</span>
</span></span></code></pre></div><p>Save and exit.</p>
<p><code>job_name</code>: You can give any name to your scrape job.<br>
<code>scrape_interval</code>: Interval in which Prometheus will scrape the metrics from the specified URL.<br>
<code>scrape_timeout</code>: If your exporter has taken more than 1m to scrape the metrics it will be a timeout.<br>
<code>metric_path</code>: This is what your endpoint’s path should be (i.e localhost:9100/metrics)<br>
<code>targets</code>: Here you can specify the number of servers on which node exporter is running with the same configuration.</p>
<h4 id="step-4-heres-the-command-to-execute-prometheus">Step 4: Here&rsquo;s The Command To Execute Prometheus:</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>~/prometheus/prometheus --storage.tsdb.path<span style="color:#f92672">=</span>/var/lib/prometheus/data/ --config.file<span style="color:#f92672">=</span>~/prometheus/prometheus.yml --web.external-url<span style="color:#f92672">=</span>http://myurl.com:9090
</span></span></code></pre></div><p>Also, don’t forget to make the same changes in your service <code>file:/etc/systemd/system/prometheus.service</code></p>
<h4 id="step-5-restart-prometheus-service">Step 5: Restart prometheus service</h4>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>sudo systemctl restart prometheus
</span></span></code></pre></div><h4 id="step-6-visiting-localhost9090-again">Step 6: Visiting Localhost:9090 Again</h4>
<p>Now visit the URL <code>localhost:9090</code>. In Expression field you can search for <code>node_filesystem_size_bytes</code> by clicking on the <code>Execute</code> button. You will get the below stats:</p>
<p><img loading="lazy" src="/img/prometheus-setup/disk_utilization.png" alt="Disk utilization graph on node Exporter"  />
</p>
<p>After clicking on the <code>graph</code>:</p>
<p><img loading="lazy" src="/img/prometheus-setup/disk_utilization_graph.png" alt="Disk utilization graph on node Exporter"  />
</p>
<h2 id="installation-with-docker">Installation with Docker</h2>
<h3 id="prometheus">Prometheus</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>docker run <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>    -p 9090:9090 <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>    -v ~/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>    prom/prometheus
</span></span></code></pre></div><h3 id="node-exporter">Node Exporter</h3>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>docker run -d <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  --net<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;host&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  --pid<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;host&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  -v <span style="color:#e6db74">&#34;/:/host:ro,rslave&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  quay.io/prometheus/node-exporter <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  --path.rootfs<span style="color:#f92672">=</span>/host
</span></span></code></pre></div><p>The rest of option will remain same as i explained in above parts.</p>
<h1 id="at-the-end">At the end</h1>
<p>Like this, you can explore each metrics like memory, CPU, etc.</p>
<p>There are already lots of exporters is available on the internet like Nginx exporter, MongoDB exporter, MySQL server exporter, etc. Just download them and start using it. You can check more info about exporter <a href="https://prometheus.io/docs/instrumenting/exporters/">here</a>.</p>
<p><strong>You have now successfully installed Prometheus and node exporters.</strong></p>
<p>If you see this <a href="https://prometheus.io/docs/introduction/overview/#architecture">official architecture diagram</a>, we have successfully set up the <strong>Prometheus</strong>, <strong>Pushgateway/Exporters</strong>, and <strong>Prometheus UI</strong>.</p>
<p>In the <a href="https://ashish.one/blogs/setup-alertmanager/">Part 2</a>, we will see how we can set up an alert manager and how to setup alert over the metrics.</p>
<p>Stay tuned for the new updates.</p>
<blockquote>
<p><strong>“NOTE: PROMETHEUS IS METRIC STORAGE SYSTEM. DON’T TRY TO STORE ANY KIND OF LOGS. IT IS NOT RECOMMENDED.”</strong></p>
</blockquote>
<p><strong>In case of any confusion or issues leave comments below :)</strong></p>
<p>Article partially posted on <a href="https://pepipost.com/tutorials/setup-prometheus-and-exporters/">Pepipost tutorial</a> by me.</p>
]]></content:encoded>
    </item>
    <item>
      <title>What should be the value of max_gram and min_gram in Elasticsearch?</title>
      <link>https://ashish.one/blogs/min-gram-and-max-gram-elasticsearch/</link>
      <pubDate>Sun, 22 Sep 2019 15:20:39 +0530</pubDate>
      <guid>https://ashish.one/blogs/min-gram-and-max-gram-elasticsearch/</guid>
      <description>&lt;p&gt;I was working on elasticsearch and the requirement was to implement like query “%text%” ( like mysql %like% ). We could use wildcard, regex or query string but those are slow. Hence i took decision to use &lt;a href=&#34;https://www.elastic.co/guide/en/elasticsearch/reference/6.2/analysis-ngram-tokenfilter.html&#34;&gt;ngram token filter&lt;/a&gt; for like query. It was quickly implemented on local and works exactly i want.&lt;/p&gt;
&lt;h2 id=&#34;the-problem&#34;&gt;The problem&lt;/h2&gt;
&lt;p&gt;To know the actual behavior, I implemented the same on staging server. I found some problem while we start indexing on staging.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>I was working on elasticsearch and the requirement was to implement like query “%text%” ( like mysql %like% ). We could use wildcard, regex or query string but those are slow. Hence i took decision to use <a href="https://www.elastic.co/guide/en/elasticsearch/reference/6.2/analysis-ngram-tokenfilter.html">ngram token filter</a> for like query. It was quickly implemented on local and works exactly i want.</p>
<h2 id="the-problem">The problem</h2>
<p>To know the actual behavior, I implemented the same on staging server. I found some problem while we start indexing on staging.</p>
<ol>
<li>Storage size was directly increase by 8x, Which was too risky. In my previous index the string type was “keyword”. Its took approx 43 gb to store the same data. I implemented a new schema for “like query” with ngram filter which took below storage to store same data.</li>
</ol>
<pre tabindex="0"><code>curl -XGET http://localhost:9200/_cat/indices?v

index       docs.count  pri.store.size
ngram-test  459483245   329.5gb
</code></pre><ol start="2">
<li>Sometime like query was not behaving properly. Not getting exact output.</li>
</ol>
<h2 id="schema">Schema</h2>
<pre tabindex="0"><code>curl -XPUT &#34;localhost:9200/ngram-test?pretty&#34; -H &#39;Content-Type: application/json&#39; -d&#39;
{
  &#34;settings&#34;:{
    &#34;index&#34;:{
      &#34;number_of_shards&#34;:5,
      &#34;number_of_replicas&#34;:0,
      &#34;codec&#34;: &#34;best_compression&#34;
    },
    &#34;analysis&#34;:{
      &#34;filter&#34;:{
        &#34;like_filter&#34;:{
          &#34;type&#34;:&#34;ngram&#34;,
          &#34;min_gram&#34;:3,
          &#34;max_gram&#34;:10,
          &#34;token_chars&#34;:[
            &#34;letter&#34;,
            &#34;digit&#34;,
            &#34;symbol&#34;
          ]
        }
      },
      &#34;analyzer&#34;:{
        &#34;like_analyzer&#34;:{
          &#34;type&#34;:&#34;custom&#34;,
          &#34;tokenizer&#34;:&#34;keyword&#34;,
          &#34;filter&#34;:[
            &#34;lowercase&#34;,
            &#34;like_filter&#34;
          ]
        }
      }
    }
  },
  &#34;mappings&#34;:{
    &#34;logs&#34;:{
      &#34;properties&#34;:{
        &#34;email&#34;:{
          &#34;type&#34;:&#34;keyword&#34;,
          &#34;fields&#34;:{
            &#34;text&#34;:{
              &#34;analyzer&#34;:&#34;like_analyzer&#34;,
              &#34;search_analyzer&#34;:&#34;like_analyzer&#34;,
              &#34;type&#34;:&#34;text&#34;
            }
          }
        }
      }
    }
  }
}&#39;
</code></pre><h2 id="analyzing-the-behavior-of-ngram-filter">Analyzing the behavior of ngram filter</h2>
<p>We made one test index and start monitoring by inserting doc one by one.</p>
<p><a href="https://medium.com/@ashishstiwari/what-should-be-the-value-of-max-gram-and-min-gram-in-elasticsearch-f091404c9a14">Continue Reading</a></p>
]]></content:encoded>
    </item>
    <item>
      <title>About me</title>
      <link>https://ashish.one/about/</link>
      <pubDate>Tue, 03 Sep 2019 15:11:45 +0530</pubDate>
      <guid>https://ashish.one/about/</guid>
      <description>&lt;p&gt;&lt;img loading=&#34;lazy&#34; src=&#34;https://ashish.one/img/speaker-pic/ashish.jpg&#34; alt=&#34;Ashish Tiwari&#34;  /&gt;
&lt;/p&gt;
&lt;p&gt;I’m a &lt;strong&gt;Principal Solutions Architect – Search &amp;amp; GenAI Specialist&lt;/strong&gt;, passionate about building and scaling search and GenAI-driven solutions. My journey started as a Software Engineer, and over the years I’ve worked across diverse stacks, databases, and programming languages—solving real-world problems and learning from some of the best minds in the industry.&lt;/p&gt;
&lt;p&gt;Having worn multiple hats in startups, I’ve gained hands-on experience in system design, architecture, scaling, coding, maintenance, customer support, marketing, and community engagement. Lately, my focus has been on Generative AI, vector search, embeddings, and Retrieval-Augmented Generation (RAG)—helping bridge the gap between unstructured data and intelligent search experiences.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p><img loading="lazy" src="/img/speaker-pic/ashish.jpg" alt="Ashish Tiwari"  />
</p>
<p>I’m a <strong>Principal Solutions Architect – Search &amp; GenAI Specialist</strong>, passionate about building and scaling search and GenAI-driven solutions. My journey started as a Software Engineer, and over the years I’ve worked across diverse stacks, databases, and programming languages—solving real-world problems and learning from some of the best minds in the industry.</p>
<p>Having worn multiple hats in startups, I’ve gained hands-on experience in system design, architecture, scaling, coding, maintenance, customer support, marketing, and community engagement. Lately, my focus has been on Generative AI, vector search, embeddings, and Retrieval-Augmented Generation (RAG)—helping bridge the gap between unstructured data and intelligent search experiences.</p>
<p>I’m an open-source enthusiast who loves contributing back and sharing knowledge through blogs, talks, and community initiatives. Outside of work, I spend time experimenting with new technologies, writing, and engaging with the community.</p>
<p>Based in Mumbai, India, this space is where I share my thoughts, learnings, and findings around the evolving world of Search and GenAI.</p>
<p>Thanks.<br>
<strong>Ashish Tiwari</strong></p>
]]></content:encoded>
    </item>
  </channel>
</rss>
