<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shamil Mehdiyev on Medium]]></title>
        <description><![CDATA[Stories by Shamil Mehdiyev on Medium]]></description>
        <link>https://medium.com/@samil.mehdiyev?source=rss-9de398fdedd1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QmrtTzbWZriyWflo6JNYaw.jpeg</url>
            <title>Stories by Shamil Mehdiyev on Medium</title>
            <link>https://medium.com/@samil.mehdiyev?source=rss-9de398fdedd1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 20:06:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@samil.mehdiyev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Go Language: Why Go and How to Set Up Your Environment]]></title>
            <link>https://medium.com/@samil.mehdiyev/go-language-why-go-and-how-to-set-up-your-environment-9d52577f0445?source=rss-9de398fdedd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d52577f0445</guid>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Shamil Mehdiyev]]></dc:creator>
            <pubDate>Tue, 19 Aug 2025 20:02:42 GMT</pubDate>
            <atom:updated>2025-08-19T20:02:42.489Z</atom:updated>
            <content:encoded><![CDATA[<p>With so many programming languages to choose from, Golang (or Go) stands out as a popular and practical choice for engineers who want to build reliable products, powerful tools, and scalable systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*hLaGPMrWHiF28UHY-omDlQ.jpeg" /></figure><p>Its simplicity, combined with a set of powerful standard libraries, gives you the power to create tools for any need, like cloud services, different types of CLIs, scalable web and/or mobile applications, and reliability tools for teams such as DevOps or SRE.</p><p>Go, which was developed by Google engineers, came to the world with a mission to solve real-world engineering problems and pain points like slow backend solutions, messy codebases, and complicated (yet sometimes poor) concurrency models. By nature, Go enforces simplicity, readability, and consistency, which makes it a pragmatic and consistent programming language with a focus on solving problems, not wrestling with frameworks or dependencies, which bring a lot of pain with them. If you want a language that balances performance like C++ with developer productivity like Python, Go is an ideal choice.</p><p><strong>Disclaimer: If you want to read it in Substack, please visit the link below.</strong></p><p><a href="https://miragebyte.substack.com/p/go-language-why-go-and-how-to-set?r=edhpq">Go Language: Why Go and How to Set Up Your Environment</a></p><p>Go is popular for its fast execution. It compiles directly into machine code, which means your computer can run it without needing an interpreter or virtual machine in between. This makes Go applications start up and run quickly, but without complexity. In practice, this means your APIs, servers, or tools built with Go can handle more requests per second while using fewer resources.</p><p>Another important aspect of Go is concurrency. In most languages, working with threads is complicated and heavy. Go solves this with goroutines, which are lightweight functions that can run at the same time with almost no extra cost. This makes it easy to build apps that handle thousands of tasks in parallel (like streaming content to millions of users, processing financial transactions, etc.) without getting stuck in complex thread management.</p><p>From an engineering perspective, Go comes with a rich standard toolkit; no need to chase third-party libraries for basic tasks. You get a formatter<strong> </strong>to keep your code clean and consistent, a testing framework for writing tests easily, and profiling tools to find performance bottlenecks. This means you spend more time coding and less time setting up your environment.</p><p>Companies like Google, Uber, Dropbox, Netflix, Twitch, Shopify, and others use Go in production because it solves real scaling problems. Go helps with problems like handling massive internal infrastructure needs, real-time geofence checks, reducing server usage, speeding up performance, handling thousands of concurrent requests to achieve high-performance networking, and improving reliability/scalability.</p><p>Apart from these companies, there are tons of examples written in Go; some of the most important developer tools like Docker, Kubernetes, Terraform, Consul, CockroachDB, and others are entirely built with Go.</p><p>That’s why Go stands out as a near-perfect choice for many engineers. Go is a practical language, not an academic one. It doesn’t try to include every feature possible. Instead, it focuses on simplicity, stability, and speed. For engineers and teams who value long-term maintainability, Go is almost a perfect choice. Even for existing systems or environments, you don’t need to rewrite everything; you can introduce it as microservices or tools and migrate smoothly.</p><p>For engineers who have just started their journey or have years of engineering experience but want to learn something new, Go can be a perfect choice, and it is intentionally easy to learn. It has fewer keywords than most languages, and no complex features like inheritance or operator overloading. Engineers from C, Java, or Python backgrounds can start using Go in days, not months.</p><p>Apart from the top tech companies I listed above, there are tons of companies from small to large whose using Go in their tech stack, so if you have Go in your arsenal, you can be spotted on their hiring radars very quickly.</p><p>And I think Go has a bright future; Go powers critical infrastructure tools like Kubernetes, Docker, etc. Its ecosystem is growing and backed by Google and major open-source communities and contributors.</p><p>So, long story short, Go helps you to build scalable, reliable, and efficient systems. Now, if you&#39;re still here, let’s see how quickly and easily we can set up this beautiful language.</p><h4>How to Set Up Your Environment</h4><p>Depending on what OS you are using, you can go to the official website (<a href="https://go.dev/dl/">https://go.dev/dl/</a>) and download the installer you want. In a matter of minutes and a few clicks (following the instructions), you will have a ready-to-use Go installed on your machine.</p><p>To verify that you installed Go properly, open your terminal (Command Prompt/PowerShell) and type:</p><pre>go version</pre><p>If everything is set up correctly, you’ll see something like this. &lt;your_version&gt; might vary depending on when you installed it and which version is the latest one.</p><pre>go version go&lt;your_version&gt; darwin/amd64</pre><p>By default, Go uses a folder called <strong>go</strong> inside your home directory to store code and packages.</p><p>On <strong>Linux/Mac</strong>, this is usually: ~/go<br>On <strong>Windows</strong>, it’s usually: C:\Users\YourName\go</p><p>Inside this folder, you’ll have:<br>bin/ → compiled executables<br>pkg/ → cached packages<br>src/ → your Go source code</p><p>To be honest with you, most of the time you won’t care about these folders, so just keep in mind that you have these folders somewhere in your machine for future reference. :)</p><p>Before closing this page, let’s quickly taste Go and find how yummy it is, of course, from an engineering perspective. I am sure you are hungry, but just get something to eat from the kitchen.</p><p>Create a folder. I used to have a “Workspace” folder where I put all my code and stuff that I am working on. Create a “golang101” folder, and inside it a “abra-cadabra-go” folder.</p><pre>mkdir Workspace/golang101/abra-cadabra-go &amp;&amp; cd abra-cadabra-go</pre><p>Create a file called “main.go” and put the code below there:</p><pre>package main<br><br>import &quot;fmt&quot;<br><br>func main() {<br>    fmt.Println(&quot;Abra Cadabra, MirageByte News!&quot;)<br>}</pre><p>Then you can run it with the command below:</p><pre>go run main.go</pre><p>If you see a message in your terminal, congrats — your environment is ready! I mean a real message, not some kind of errors in the terminal. If you have some issues, just try again, start from the beginning, or drop a message in the comment section below. I will be happy to help you.</p><p>In the next articles, I will use VS Code as an IDE, so if you have already installed it, you can install the Go extension (see the screenshot below), or you can download and install it via the link (<a href="https://code.visualstudio.com/">https://code.visualstudio.com/</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wc4WkIsrB2sGbgcLLxC2KQ.png" /></figure><p>If you are still here with me, I want to say thank you for your valuable time spent with me reading this article. Please follow me here, or if you&#39;re a Substack lover, consider subscribing to the Mirage Bytes Newsletter.</p><p><a href="https://miragebyte.substack.com/">MirageByte News | Shamil Mehdiyev | Substack</a></p><p>Cheers, and see you in the next one.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d52577f0445" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to develop your own OpenAI plugin using Golang]]></title>
            <link>https://medium.com/@samil.mehdiyev/how-to-develop-your-own-openai-plugin-using-golang-257d726e7a38?source=rss-9de398fdedd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/257d726e7a38</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[plugins]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Shamil Mehdiyev]]></dc:creator>
            <pubDate>Wed, 14 Jun 2023 18:31:47 GMT</pubDate>
            <atom:updated>2023-06-14T18:31:47.807Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BvjGhtqOfyL2-_63" /><figcaption>Photo by <a href="https://unsplash.com/@adamkool?utm_source=medium&amp;utm_medium=referral">Adam Kool</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this post, We will discuss, how to develop your own OpenAI plugin using Golang. As a case study, we will create a Weather Plugin.</p><blockquote>What are OpenAI plugins? OpenAI plugins bridge the gap between ChatGPT and third-party applications, allowing ChatGPT to interact with APIs defined by developers. This enhances ChatGPT’s capabilities, enabling it to perform a wide variety of actions.</blockquote><p>To construct a plugin, we will follow these steps:</p><ul><li>Create a plugin manifest file</li><li>Build an OpenAPI specification file</li><li>Develop the APIs</li><li>Register a plugin</li><li>Activate a plugin</li></ul><p><strong>STEP 1: Create a plugin manifest file</strong></p><p>Every plugin requires an ai-plugin.json file to be hosted on the domain of the API. For instance, a company named example.com would make the plugin JSON file accessible via https://example.com, the location of their API.</p><p>When installing the plugin via the ChatGPT UI, ChatGPT will check the backend for a file located at ./well-known/ai-plugin.json.</p><p>The ./well-known/ai-plugin.json folder is necessary on your domain for ChatGPT to connect with your plugin.</p><p>If the file is absent, the plugin installation will fail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NClP4IfKHFh_X8pb" /></figure><p>Here are the key parameters of the manifest file:</p><ul><li><strong>schema_version</strong>: The manifest schema version.</li><li><strong>name_for_model</strong>: Name of the model that will target the plugin. The name can contain only letters and numbers, no spaces, with a maximum of 50 characters.</li><li><strong>name_for_human</strong>: Human-readable name with a maximum length of 20 characters.</li><li><strong>description_for_model</strong>: Description of the model. An elaborate and detailed description facilitates a better plugin experience. The maximum length is 8000 characters.</li><li><strong>description_for_human</strong>: Human-readable description of the plugin, with a 100 characters limit.</li><li><strong>auth</strong>: Authentication schema for interacting with the plugin.</li><li><strong>api</strong>: API specification URL path. This is where the ChatGPT will look for an OpenAPI specification file.</li><li><strong>logo_url</strong>: URL to fetch the logo. Suggested size: 512 x 512. Transparent backgrounds are supported, and only image formats are allowed; no GIFs.</li></ul><p><strong>STEP 2: Build an OpenAPI specification file</strong></p><p>Next, you need to construct the OpenAPI specification to document the API. The model in ChatGPT only knows about your API based on what is defined in the OpenAPI specification and the manifest file. In our example, the OpenAPI specification will look as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IigCK_azEAA5YYyU" /></figure><p>In the specification file, you need to define at least one <strong>paths</strong> field, a <strong>components</strong> field, OR a <strong>webhooks</strong> field.</p><p>The OpenAPI Specification (OAS) provides a standard, language-agnostic interface to HTTP APIs, enabling both humans and computers to discover and understand the service’s capabilities without access to the source code, documentation, or network traffic inspection.</p><p>When appropriately defined, a consumer can interact with the remote service with minimal implementation logic. An OpenAPI specification file can be used by documentation generation tools to display the API and by code generation tools to create servers and clients in various programming languages.</p><p>You can find the OpenAPI specifications in the “References” section at the end of this article. However, I’d like to highlight some key properties of the OpenAPI specification file:</p><ul><li><strong>path</strong>: This field is a relative path to an individual endpoint. The field name MUST begin with a forward slash (/).</li><li><strong>post</strong>: A definition of a POST operation on this path.</li><li><strong>requestBody</strong>: Applicable for this operation. The requestBody is fully supported in HTTP methods where the HTTP 1.1 specification RFC7231 has explicitly defined semantics for request bodies.</li><li><strong>content</strong>: The content of the request body. The key is a <strong>media type</strong> or media type range and the value describes it. In our case, it is “application/json”.</li><li><strong>schema/$ref</strong>: The schema defining the content of the request, response, or parameter. We use a reference object, a simple object to allow referencing other components in the OpenAPI document, internally and externally. The $ref string value contains a URI, which identifies the location of the referenced value.</li><li><strong>responses</strong>: A container for the expected responses of an operation.</li><li><strong>components</strong>: ​​This section holds a set of reusable objects for different aspects of the OAS (The OpenAPI Specification). All objects defined within the components object will not affect the API unless they are explicitly referenced from properties outside the components object.</li></ul><p><strong>STEP 3: Develop APIs</strong></p><p>Having prepared all the necessary files, let’s move to the third step: coding some APIs. We will need the following:</p><ul><li>/openapi.yaml — GET, to fetch the OpenAPI specification file.</li><li>/.well-known/ai-plugin.json — GET, to get the manifest file.</li><li>/logo.png — GET operation, to retrieve the plugin’s logo image.</li><li>/wttr — POST operation, this is an API that will implement to integrate with ChatGPT.</li></ul><p>The first three APIs are crucial for integration with Chat GPT.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/602bf62724e3892149e740de9081ee42/href">https://medium.com/media/602bf62724e3892149e740de9081ee42/href</a></iframe><p><strong>STEP 4: Plugin Registration</strong></p><p>In this step, I will register the plugin as localhost and use it in the ChatGPT UI. First, I need to run the code so that it’s available when I call it via Chrome or Postman. To run the code, simply execute the following command in the terminal:</p><pre>go run main.go</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_AGOgNS8xVxRoTYl" /></figure><p>To check if the server is running, I can telnet localhost 5004 or just open the browser and type `<a href="http://localhost:5004/">http://localhost:5004</a>`.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z8LVzOdvXYvz45vS" /></figure><p>At this point, I can confirm that the server is running even though I get a 404 Page Not Found error.</p><p>To register a plugin in ChatGPT, you need a paid subscription (Chat GPT Plus), and the account should be whitelisted to register the plugin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*za9w_mXICekus0-9" /></figure><p>When you click on the “Develop your own plugin” button (red lined), you will see a popup where you can add your domain `localhost:5004` and click the “Find manifest file” button.</p><p>Unfortunately, I encounter the first error during the process: “Failed to fetch localhost manifest. Check to ensure your localhost is running and your localhost server has CORS enabled.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pR12YhwRQXv-LtSU" /></figure><blockquote><strong>What is the CORS?</strong></blockquote><blockquote>CORS stands for Cross-Origin Resource Sharing, an HTTP mechanism that allows secure resource sharing from one origin to another. It’s a mechanism that relaxes the same-origin policy of modern internet browsers. You can read more about CORS in the References section.</blockquote><p>CORS supports requests and data transfers between cross-origin browsers and servers to be carried out securely. It relies on a mechanism that checks whether the server will permit requests from other origins to make sure that the cross-origin requests are safe.</p><p>Whenever a website tries to make a cross-origin request, the browser will add these CORS headers to the request:</p><p>Origin</p><blockquote>Access-Control-Request-Method<br>Access-Control-Request-Headers</blockquote><p>The server will return a response with some of these CORS headers to allow or block the request:</p><blockquote>Access-Control-Allow-Origin<br>Access-Control-Allow-Credentials<br>Access-Control-Expose-Headers<br>Access-Control-Max-Age<br>Access-Control-Allow-Methods<br>Access-Control-Allow-Headers</blockquote><p><strong>— Why Does a CORS Error Occur? —</strong></p><p>A CORS error occurs when the server doesn’t return the necessary CORS headers.</p><p>Let’s fix this issue. To do this, I need to add an “Access-Control-Allow-Origin” header to a response. We can make this change in the pluginManifest method:</p><pre>func pluginManifest(w http.ResponseWriter, r *http.Request) {<br> file, err := os.Open(&quot;./.well-known/ai-plugin.json&quot;)<br> if err != nil {<br>  fmt.Println(err)<br> }<br><br> defer file.Close()<br><br> byteValue, _ := ioutil.ReadAll(file)<br> <br> //added line<br> w.Header().Set(&quot;Access-Control-Allow-Origin&quot;, &quot;https://chat.openai.com&quot;)<br> w.Header().Set(&quot;Content-Type&quot;, &quot;application/json&quot;) <br> w.Write(byteValue)<br>}</pre><p>After restarting the HTTP server, I retry to register it in the Chat GPT UI. But I encounter a new error, although this means we have made some progress.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IO2AKiqd52SNF7_f" /></figure><p>By activating “Developer Tools” in Chrome and retrying, I can see the error and gain insight into the issue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_y-E7WPt6Lsf5hAS" /></figure><p>Once again, we encounter a CORS issue, but now it happens when ChatGPT tries to fetch the OpenAPI Specification file. Let’s fix it and retry by adding the same header to the `openApiSpec` method response and to the `pluginLogo` method to avoid the same issue with this method.</p><pre>func openApiSpec(w http.ResponseWriter, r *http.Request) {<br> file, err := os.Open(&quot;openapi.yaml&quot;)<br> if err != nil {<br>  fmt.Println(err)<br> }<br><br> defer file.Close()<br><br> byteValue, _ := ioutil.ReadAll(file)<br> <br> //added line<br> w.Header().Set(&quot;Access-Control-Allow-Origin&quot;, &quot;https://chat.openai.com&quot;)<br> w.Header().Set(&quot;Content-Type&quot;, &quot;text/yaml&quot;)<br> w.Write(byteValue)<br>}<br><br>func pluginLogo(w http.ResponseWriter, r *http.Request) {<br> file, err := os.Open(&quot;logo.png&quot;)<br> if err != nil {<br>  fmt.Println(err)<br> }<br><br> defer file.Close()<br><br> byteValue, _ := ioutil.ReadAll(file)<br> <br> //added line<br> w.Header().Set(&quot;Access-Control-Allow-Origin&quot;, &quot;https://chat.openai.com&quot;)<br> w.Header().Set(&quot;Content-Type&quot;, &quot;image/png&quot;)<br> w.Write(byteValue)<br>}</pre><p>After restarting the server, we have successfully installed the plugin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KZA8BuBPqLiDIM1D" /></figure><p>However, when I try to use it again, I face the CORS error. As I did before, I will add the same header to the response of the API called ‘wttr’ and test it, but the result is the same, CORS error still exists.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9JbBZs3FT7jVxO4G" /></figure><p>But now, the same fix did not work this time. So, what’s the problem? After a few hours of research, I found a Golang package named “Go CORS handler”. This package helps to initialize a net/http handler implementing Cross-Origin Resource Sharing W3 specification in Golang. You can find the link to the GitHub repository in the References section below.</p><pre>func main() {<br> fmt.Println(&quot;Server running on port 5004&quot;)<br><br> mux := http.NewServeMux()<br><br> mux.HandleFunc(&quot;/openapi.yaml&quot;, openApiSpec)<br> mux.HandleFunc(&quot;/.well-known/ai-plugin.json&quot;, pluginManifest)<br> mux.HandleFunc(&quot;/logo.png&quot;, pluginLogo)<br> mux.HandleFunc(&quot;/wttr&quot;, getCityWttr)<br><br> handler := cors.New(cors.Options{<br>  AllowedOrigins:      []string{&quot;https://chat.openai.com&quot;},<br>  AllowCredentials:    true,<br>  AllowedHeaders:      []string{&quot;*&quot;},<br>  AllowedMethods:      []string{http.MethodGet, http.MethodPost, http.MethodDelete, http.MethodOptions},<br>  AllowPrivateNetwork: true,<br>  Debug:               true,<br> }).Handler(mux)<br><br> http.ListenAndServe(&quot;:5004&quot;, handler)<br>}</pre><p>Let’s try the plugin after the changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HQ5Ex3ZEl_wBwbxw" /></figure><p>Congratulations! We did it. Feel free to leave a comment, feedback, or thoughts about the article. You can find the <a href="https://github.com/SamilMehdiyev/openai-weather-plugin-golang">GitHub</a> repo as well.</p><p>Stay safe, and cheers. Thank you for your time. Claps and comments are much appreciated, or support me via the <a href="https://www.buymeacoffee.com/shmehdiyev">Buy Me a Tea</a> :) link.</p><p>References:</p><ul><li><a href="https://github.com/SamilMehdiyev/openai-weather-plugin-golang">https://github.com/SamilMehdiyev/openai-weather-plugin-golang</a></li><li><a href="https://platform.openai.com/docs/plugins/introduction">https://platform.openai.com/docs/plugins/introduction</a></li><li><a href="https://platform.openai.com/docs/plugins/getting-started">https://platform.openai.com/docs/plugins/getting-started</a></li><li><a href="https://swagger.io/specification/">https://swagger.io/specification/</a></li><li><a href="https://www.bannerbear.com/blog/what-is-a-cors-error-and-how-to-fix-it-3-ways/">https://www.bannerbear.com/blog/what-is-a-cors-error-and-how-to-fix-it-3-ways/</a></li><li><a href="https://openweathermap.org/">https://openweathermap.org</a></li><li><a href="https://github.com/rs/cors">https://github.com/rs/cors</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=257d726e7a38" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Maximum XOR After Operations]]></title>
            <link>https://medium.com/@samil.mehdiyev/maximum-xor-after-operations-46adf412c16d?source=rss-9de398fdedd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/46adf412c16d</guid>
            <category><![CDATA[bit-manipulation]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[interview-preparation]]></category>
            <category><![CDATA[leetcode-medium]]></category>
            <category><![CDATA[leetcode]]></category>
            <dc:creator><![CDATA[Shamil Mehdiyev]]></dc:creator>
            <pubDate>Mon, 23 Jan 2023 04:44:32 GMT</pubDate>
            <atom:updated>2023-01-23T04:44:32.656Z</atom:updated>
            <content:encoded><![CDATA[<h4>Maximum XOR After Operations — Leetcode</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gusbO-erSUL1RX-T" /><figcaption>Photo by <a href="https://unsplash.com/@garrhetsampson?utm_source=medium&amp;utm_medium=referral">Garrhet Sampson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this post, we will go through the problem from the <a href="https://leetcode.com/problems/maximum-xor-after-operations/">Leetcode 2317</a>. Maximum XOR After Operations. The question itself is very tricky. So, before the explanation, let’s see the problem itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MqzfCPbUKbHttITp" /></figure><p>First, let’s figure out the question. Having read all the conditions and constraints, we can conclude that we have an array of <strong>non-negative</strong> integers. Simple yet, let’s move on.</p><p>“In one operation, select <strong>any</strong> non-negative integer `x` and an index `i`, then update `nums[i]` to be equal to `nums[i] AND (nums[i] XOR x)`.”</p><p>At first glance, it seems simple. We just need to pick up an `x` and an index `i` and perform the above-defined expression on the number `nums[i]`. What is the `x` exactly, and what is the range of value for it? Since there is no information about `x` in the constraints section, we do not know that for sure. It could be anything.</p><p>The operation itself is not complicated, so there is one XOR operation and one AND operation. By the way, the question defines them as a binary definition. It is a hint that we will use to solve the problem. We will come back to the operation a bit later.</p><p>And last, what do we need to return? We should return the <strong>maximum</strong> possible bitwise XOR of all elements of `nums` after applying the operation <strong>any number</strong> of times. Wow, another tricky point to confuse us during the solution. The “<strong>any number</strong> of times” says that we may or not perform the operation on the arbitrary element an undefined number of times until we get the <strong>maximum</strong> possible XOR of all the elements. We are lucky, simply asked to return the possible maximum result. Neither particular `x` nor times of execution of the operation on any of `nums[i]` with chosen `x`? So, let’s focus on the <strong>maximum</strong> possible XOR instead of `x` or `i`.</p><p>Next, let’s check the given examples. In the first example, `x` is defined as a 4, and if you check the array `nums`, then you may probably think that the picked number 4 is from the given array, but it is not. There is no such condition in the question, and there is no relationship between the two. `x` can be any number, but it doesn’t matter. You will see why a bit later.</p><p>In example 2, we don’t perform any operation and just return the XOR of all the elements, as this is the <strong>maximum</strong> possible XOR.</p><p>So, now let’s start thinking about a solution. As an output, we were asked to return the <strong>maximum</strong> possible XOR of all elements. What does this mean? It means that to get the maximum result, we should have 1s (ones) in a binary representation as much as possible. First, let’s do a simple XOR operation on any arbitrary two numbers, for instance, 6 and 9.</p><p>The binary representation of 6 (six) is `110`, and for 9 (nine), it is `1001`. Now, let’s perform a binary XOR operation on them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sDxUMmftugMgWP1F" /></figure><p>So, as we can see, all the bits in the result are 1s (ones), which gives us the maximum possible XOR of the elements. Let’s take the second example from the question and explore it a bit deeper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*I30aJsDFMPRNo70o" /></figure><p>From the result, we can see that almost all the bits are 1s (ones), except for the line which is surrounded by the red rectangle. From these two examples, we can decide that the `nth` bit of the XOR of all the elements is 1(one) if the `nth` bit is 1 for an odd number of the elements, in other words, if a count of 1s (ones) is odd. (all red lines for the least significant bit).</p><p>Now, let’s move on and check the operation. To simplify, I changed the definition a bit to simplify the explanation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H-gPxlucmQE-lZo1" /></figure><p>So, the operation helps us to change any bit to get a possible maximum result. In other words, the operation `nums[i] &amp; (nums[i] XOR x)` cannot be more than `nums[i]` because we are taking AND operation on them. So, this implies that for any number we can set the bits OFF (only the bits which are already ON (1)). But we cannot set any bit ON if it was OFF already.</p><p>Let’s check the first example from the question one more time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JAXNClE8Zbr1V6-I" /></figure><p>So, as we can see in the 3rd column (counting goes from right to left), we have 2 bits which are one-s. And when we do an XOR operation on them, we will get 0, but instead, we need it to be 1 (one), to get a possible maximum result.</p><p>Which binary operation can help us? Let’s say AND bitwise operation, the result of 0 &amp; 0 &amp; 1 &amp; 1 will be 0 (zero), which is not what we need. What about OR? Okay, let’s check it out. 0 | 0 | 1 | 1 will be 1 (one).</p><p>WHAT? You may ask: “What kind of relationship do we have between OR and our question”?. As I said earlier, we are lucky just to be asked about the possible maximum result. Therefore, we can say that we will need to set bits ON and OFF for all numbers in such a way that <strong>the maximum XOR of all the numbers is equal to the OR of all numbers</strong>. Just simple.</p><p>To be honest, I was shocked when I checked others’ solutions and realized that the solution with OR binary operation was plain sailing and straightforward. It is the question that confused us with its condition, and unnecessary additional information, which caused me to move in the wrong way. And yes, my solution had O(n power of 2) time complexity, which is not the best solution.</p><p>So, be patient and practice. It will help you to be more comfortable with questions, regardless of what a question asks. Thank you for the time you spent reading this post. Please feel free to drop some comments or feedback. Stay tuned. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46adf412c16d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Google Maps into React Native App on Android]]></title>
            <link>https://medium.com/@samil.mehdiyev/integrating-google-maps-into-react-native-app-on-android-40c984c0e4f2?source=rss-9de398fdedd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/40c984c0e4f2</guid>
            <category><![CDATA[google-maps]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Shamil Mehdiyev]]></dc:creator>
            <pubDate>Fri, 12 Apr 2019 20:54:59 GMT</pubDate>
            <atom:updated>2022-03-10T10:29:40.460Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*156RH4DGtvYxAAgM" /><figcaption>Photo by <a href="https://unsplash.com/@carlheyerdahl?utm_source=medium&amp;utm_medium=referral">Carl Heyerdahl</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In previous days, I wrote about, how to integrate Google Maps in React Native App on iOS, you can find it <a href="https://medium.com/@samil.mehdiyev/integrating-google-maps-in-react-native-app-on-ios-656da9f1e40f">here</a>. I didn’t mix both integration processes in one post, because of the scope of information. That is why they are two separate posts, one for the iOS Platform, second for the Android Platform.</p><p>In this post, I will explain how to integrate Google Maps into React Native on Android.</p><p>Let’s START</p><p><strong>Step 1</strong>: Create React Native Application</p><p>We create a React Native application from scratch using react-native-cli to show, step by step, how everything is installed. If you haven’t installed React Native, you can find how to install it in <a href="https://facebook.github.io/react-native/docs/getting-started">the official documentation</a>.</p><p>Now we can create our app, simply using<br>react-native init MapsAndroidDemoApp in a command line.</p><p><strong>Step 2</strong>: Install react-native-maps package</p><p>As a reference, you can find the installation process of react-native-maps in this <a href="https://github.com/react-native-community/react-native-maps/blob/master/docs/installation.md">documentation</a>, but we will walk through all of the steps and include screenshots for better understanding. First, you need to change your directory via the command cd MapsAndroidDemoApp.</p><p>Now let’s install the package with the following npm install --save react-native-maps command.</p><p><strong>Step 3</strong>: Configuration on Android</p><p>Now, let’s open Android Studio and do some configurations.</p><p>1. Open the <em>android/settings.gradle</em> file and define the <em>react-native-maps</em> project. Simply copy and paste the following lines:</p><pre>...</pre><pre>include &#39;:react-native-maps&#39;</pre><pre>project(&#39;:react-native-maps&#39;).projectDir = new File(rootProject.projectDir, &#39;../node_modules/react-native-maps/lib/android&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HAN43eoVedsjyBeer3D-uA.png" /><figcaption>The “settings.gradle” file is under the “android” folder (file selected in the Project Navigator)</figcaption></figure><p>2. After, we will open a <em>build.gradle</em> file under <em>android/app/</em> folder (<em>“android/app/build.gradle”</em>) and add react-native-maps as a dependency into the “dependencies” section:</p><pre>...<br>dependencies {<br>   ...<br>   implementation project(&#39;:react-native-maps&#39;)<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XVUg5E6xwWktrMlwMT_7lw.png" /><figcaption>“build.gradle” file under “android/app” folder (file selected in Project Navigator)</figcaption></figure><p>3. If you’ve defined project-wide properties, <strong>which is recommended</strong> by the <a href="https://github.com/react-native-community/react-native-maps/blob/master/docs/installation.md">documentation</a>, open a build.gradle file under the android folder. Find an “ext” section and add the following lines:</p><pre>ext {<br>   ...<br>   googlePlayServicesVersion = &quot;11.8.0&quot;<br>   androidMapsUtilsVersion = &quot;0.5+&quot;<br>}</pre><p><strong>IF YOU DID THE PREVIOUS STEP, SKIP THIS STEP</strong></p><p>4. If you do <strong>not</strong> have <em>project-wide properties</em> defined and have a different play-services version than the one included in this library, use it instead.</p><p>Open the build.gradle file under the “<em>android/app/” </em>folder (<em>“android/app/build.gradle”</em>) and add the following piece of code into the “dependencies” section:</p><pre>...<br>dependencies {<br>...</pre><pre>implementation(project(&#39;:react-native-maps&#39;)){<br>      exclude group: &#39;com.google.android.gms&#39;, module: &#39;play-services-base&#39;<br>      exclude group: &#39;com.google.android.gms&#39;, module: &#39;play-services-maps&#39;<br>   }</pre><pre>implementation &#39;com.google.android.gms:play-services-base:10.0.1&#39;<br>   implementation &#39;com.google.android.gms:play-services-maps:10.0.1&#39;<br>}</pre><p><strong>Step 4</strong>: Create a Google Maps API Key</p><p>Note: I will use the Key, which I have created before (for the iOS version of React Native App, you can find it <a href="https://medium.com/@samil.mehdiyev/integrating-google-maps-in-react-native-app-on-ios-656da9f1e40f">here</a>).</p><p>In order to use Google maps, we will need to create a <a href="https://developers.google.com/maps/documentation/ios-sdk/get-api-key">Google Maps API key</a>. Click <strong>“Get Started”</strong> Button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*gvjII0CWIikAiXEjhyQF5g.png" /><figcaption>Click “GET STARTED” button</figcaption></figure><p>After that, we will see another pop-up and there we need to choose “Maps” and click “Continue”.</p><p>Then, we will see a section where we need to choose the project. Choose “Create a new project” in the drop-down menu and name it “<em>MapsAndroidDemoApp</em>”, then click “Next”.</p><p>After a few steps, we will see confirmation pop-up window, which says that “You’re all set”. Copy the “Key” for future actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gQxJm5Pi_ruLnlmIMdFEog.png" /></figure><p><strong>Step 5</strong>: Specify the Google Maps API Key</p><p>After previous steps, we need to specify our Google Maps API Key into the manifest file. Open the AndroidManifes.xml file under the “android/app/src/main/” folder. Then, add the following “meta-data” XML tag into the “application” XML tag.</p><pre>&lt;application&gt;</pre><pre>&lt;!-- You will only need to add this meta-data tag, but make sure it&#39;s a child of application --&gt;</pre><pre>&lt;meta-data<br>   android:name=&quot;com.google.android.geo.API_KEY&quot;<br>   android:value=&quot;Your Google maps API Key Here&quot;/&gt;<br>&lt;/application&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zrWn5osXCKHn-xG7xTJ8rA.png" /><figcaption>AndroidManifest.xml file</figcaption></figure><p><strong>Step 6</strong>: The last step of configuration</p><p>Open the “MainApplication.java” file under the “android/app/src/main/java/…” folder and add the followings:</p><p>1) We need to import a “MapsPackage” class into the “MainApplication”.</p><pre>import com.airbnb.android.react.maps.MapsPackage;</pre><p>2) We need to add the following line:</p><pre>@Override<br>protected List&lt;ReactPackage&gt; getPackages() {<br>   return Arrays.&lt;ReactPackage&gt;asList(<br>      new MainReactPackage(),<br>      new MapsPackage()<br>   );<br>}</pre><p><strong>Step 7</strong>: I’m trying to build and “Build Failed” Wow!!!.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FnVTa8D8zJUc2A%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FnVTa8D8zJUc2A%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FnVTa8D8zJUc2A%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd1eb0030fd89ae39950118fe13cf2cd/href">https://medium.com/media/bd1eb0030fd89ae39950118fe13cf2cd/href</a></iframe><p>Let’s solve the problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qn3kXIqAUza13siGy50VQQ.png" /><figcaption>Error! Error! Error!</figcaption></figure><p>I found the discussion about this problem on the GitHub (read <a href="https://github.com/react-native-community/react-native-maps/issues/2695">#2695</a>). As mentioned there, “the issues are related to other packages you include in the project”. To fix this error, please check the following comment (find it <a href="https://github.com/react-native-community/react-native-maps/issues/2695#issuecomment-464637344">here</a>).</p><p>Click “Open File” link, which will open the build.gradle file under the react-native-maps. Add the following line to the end of the file in the dependencies declaration.</p><pre>implementation &quot;com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}&quot;</pre><p><strong>Step 8</strong>: Let’s change the App.js file.</p><p>1) Import “react-native-maps” package into App.js:</p><pre>import MapView from &#39;react-native-maps&#39;;</pre><p>2) The render method will be very basic since it only needs to display the map to the user, as follows:</p><pre>&lt;MapView<br>    initialRegion={{<br>      latitude: 37.78825,<br>      longitude: -122.4324,<br>      latitudeDelta: 0.0922,<br>      longitudeDelta: 0.0421,<br>    }}<br>/&gt;</pre><p>3) We are using the same latitudeDelta and longitudeDelta<em>,</em> which shown in the <a href="https://github.com/react-native-community/react-native-maps">documentation</a>, but feel free to play around with those coordinates.</p><p>Also, don’t forget to add some styles to the map. Without styles, a simulator (or a device) will not display the map. We are simply adding “map” style (lines 35–37) in StyleSheet object and show it in style attribute of “MapView” component (line 18).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*VIWlHHIwvCIjuGd11SpSjw.png" /></figure><p><strong>Step 8</strong>: Run the React Native App</p><p>And that’s it for the set-up, now we can run our React Native app. We need to navigate to “<em>MapsAndroidDemoApp</em>” folder and run the command <em>react-native run-android</em>.</p><p>But before, you need a running android simulator (check this <a href="https://facebook.github.io/react-native/docs/running-on-device.html#running-your-app-on-android-devices">link</a>).</p><p>After running the app, our simulator, hopefully, will display a beautiful map! If it’s showing a blank screen with the Google logo in the bottom left corner you might need to enable your <a href="https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend">Google Maps API key</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*neUMBh1_sphgQrpE__FVmw.png" /><figcaption>Result</figcaption></figure><p>CONCLUSION</p><p>That’s it. I hope this article will save someone a lot of time. Please, if you see any mistakes don’t hesitate to leave a comment, Give this article clap if you find it helpful. You can find source code in my <a href="https://github.com/SamilMehdiyev/react-native-maps-android-demo-app">GitHub repo</a>.</p><p>If you like my content :) <a href="https://www.buymeacoffee.com/shmehdiyev">https://www.buymeacoffee.com/shmehdiyev</a></p><p>Happy coding and Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40c984c0e4f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Google Maps in React Native App on iOS]]></title>
            <link>https://medium.com/@samil.mehdiyev/integrating-google-maps-in-react-native-app-on-ios-656da9f1e40f?source=rss-9de398fdedd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/656da9f1e40f</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[google-maps]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Shamil Mehdiyev]]></dc:creator>
            <pubDate>Sun, 07 Apr 2019 14:59:22 GMT</pubDate>
            <atom:updated>2022-03-10T10:30:48.126Z</atom:updated>
            <content:encoded><![CDATA[<h3>Integrating Google Maps into React Native App on iOS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RERqENJXiignUe3AU4W-ng.png" /></figure><p>Nowadays, almost every application which we are using on a daily basis, have a map feature. During the development process of my mobile application, I faced a lot of errors when I tried to integrate the map feature into the app. It took me a few nights to successfully integrate it and finish the app. So, in this post, we will go through the integration process of Google Maps into a React Native app.</p><blockquote>UPDATED, Now Android version is available.</blockquote><p>In this post, I will explain how to integrate react-native-maps into iOS. But, if you are interested in Android, you can find it here, “<a href="https://medium.com/@samil.mehdiyev/integrating-google-maps-into-react-native-app-on-android-40c984c0e4f2">Integrating Google Maps intoReact Native App on Android</a>”.</p><p>Let’s START</p><p><strong>Step 1</strong>: Create React Native Application</p><p>We create a React Native application from scratch using react-native-cli to show, step by step, how everything is installed. If you haven’t installed React Native, you can find how to install it in <a href="https://facebook.github.io/react-native/docs/getting-started">the official documentation</a>.</p><p>Now we can create our app, simply using react-native init MapsApp in a command line.</p><p><strong>Step 2</strong>: Install react-native-maps package</p><p>As a reference, you can find the installation process of react-native-maps in this <a href="https://github.com/react-native-community/react-native-maps/blob/master/docs/installation.md">documentation</a>, but we will walk through all of the steps and include screenshots for better understanding. First, you need to change your directory via the command cd MapsApp.</p><p>Let’s install the package with the following npm install --save react-native-maps command.</p><p><strong>Step 3</strong>: Configuration on iOS</p><p>Next, we run react-native link react-native-maps after which you should be able to use this library on iOS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*rD5LhztpNyzfFRjmcB9gHA.png" /><figcaption>After running “react-native link react-native-maps” command, you will see similar information like this one</figcaption></figure><p>Note that by default this will use Apple Maps and you will miss some of the features provided by Google. To enable Google Maps, we will follow the below instructions.</p><p><strong>Step 4</strong>: Enable Google Maps on iOS</p><p>We will use the Cocoapods. We will create a Podfile where we will specify the dependencies of our iOS application. Navigate to “ios/” folder in MapsApp folder and run the following pod init command in the command line.</p><p>Setup Podfile (found as below, replacing all references to _YOUR_PROJECT_TARGET_ with our project target (it’s the same as project name by default, which in our case is “MapsApp”). Copy and Paste below content and replace all references</p><p>To enable Google Maps on iOS, uncomment lines 37–39.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nMoHzQpALBbDVI7zegouFQ.png" /><figcaption>Uncomment lines 37–39, for enabling Google Maps on iOS</figcaption></figure><p>Next, we need to install the Pods. Run the following pod install command in the command line.</p><p>Next, we will open the produced workspace file (.<em>xcworkspace</em>) in “XCode” to build our project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*AKDUctvihroru9v7SWml8A.png" /><figcaption>Open MapsApp.xcworkspace</figcaption></figure><p><strong>Step 5</strong>: Create a Google Maps API Key</p><p>In order to use Google maps, we will need to create a <a href="https://developers.google.com/maps/documentation/ios-sdk/get-api-key">Google Maps API key</a>. Click <strong>“Get Started”</strong> Button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*gvjII0CWIikAiXEjhyQF5g.png" /><figcaption>Click “GET STARTED” button</figcaption></figure><p>After that, we will see another pop-up and there we need to choose “Maps” and click “Continue”.</p><p>Then, we will see a section where we need to choose the project. Choose “Create a new project” in the drop-down menu and name it “MapsApp”, then click “Next”.</p><p>After a few steps, we will see confirmation pop-up window, which says that “You’re all set”. Copy the “Key” for future actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gQxJm5Pi_ruLnlmIMdFEog.png" /></figure><p><strong>Step 6</strong>: Back to the Code</p><p>To enable Google Maps on iOS, copy the Google API key and edit AppDelegate.m file. Insert these two lines into your AppDelegate.m file:</p><pre>#import &lt;GoogleMaps/GoogleMaps.h&gt;</pre><pre>[GMSServices provideAPIKey:@&quot;_YOUR_API_KEY_&quot;]; // add this line using the api key obtained from Google Console</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*o58sz4swqhevtqWNez58sQ.png" /><figcaption>Add the above lines and Google API Key</figcaption></figure><p>Let’s build our project (“XCode -&gt; Product -&gt; Build”). Really!!! After all these steps “Build Failed”. We have the following error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Whzy61rTTJNPk8jrMLnsvg.png" /><figcaption>The error which causes build failing</figcaption></figure><p>In this post, we will not dive into details of this error. We only fix it and continue our development. What we do need to do?</p><p>First of all, in “Project Navigator” choose project “MapsApp”. After, open section “Link Binary With Libraries” under “Build Phases”. Delete “libAirMaps.a” in the list, and try to rebuild project again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0-SRbTVRsKKfDGjs2nbMmw.png" /><figcaption>Remove it</figcaption></figure><p><strong>Step 7</strong>: Let’s begin building out the app by changing some codes in the App.js file.</p><p>1) Import “react-native-maps” package into App.js:</p><pre>import MapView from &#39;react-native-maps&#39;;</pre><p>2) The render method will be very basic since it only needs to display the map to the user, as follows:</p><pre>&lt;MapView<br>    initialRegion={{<br>      latitude: 37.78825,<br>      longitude: -122.4324,<br>      latitudeDelta: 0.0922,<br>      longitudeDelta: 0.0421,<br>    }}<br>/&gt;</pre><p>3) We are using the same latitudeDelta and longitudeDelta<em>,</em> which shown in the <a href="https://github.com/react-native-community/react-native-maps">documentation</a>, but feel free to play around with those coordinates.</p><p>Also, don’t forget to add some styles to the map. Without styles, a simulator (or a device) will not display the map. We are simply adding “map” style (lines 35–37) in StyleSheet object and show it in style attribute of “MapView” component (line 18).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*VIWlHHIwvCIjuGd11SpSjw.png" /></figure><p><strong>Step 8</strong>: Run the React Native App</p><p>And that’s it for the set-up, now we can run our iOS app. Last time we are navigating into “ios” folder, now we need to navigate to “MapsApp” folder and run react-native run-ios command, which should open your iOS simulator.</p><p>After running the app, our simulator, hopefully, will display a beautiful map! If it’s showing a blank screen with the Google logo in the bottom left corner you might need to enable your <a href="https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend">Google Maps API key</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aKQ1UeH0-nfCkC0WQanqdg.png" /><figcaption>Result</figcaption></figure><p><strong>CONCLUSION</strong></p><p>That’s it. WE ARE FINISH, now we have App, which displays Google Maps in our “MapsApp” application. Please, if you see any mistakes don’t hesitate to leave a comment, any feedback and suggestions are acceptable.</p><p>I hope you enjoyed when reading this article. You can find source code in my <a href="https://github.com/SamilMehdiyev/MapsApp">GitHub repo</a>. Happy coding.</p><p>If you like my content :) <a href="https://www.buymeacoffee.com/shmehdiyev">https://www.buymeacoffee.com/shmehdiyev</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=656da9f1e40f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ELK STACK ON WINDOWS SERVER — PART 3 — CUSTOMIZATION]]></title>
            <link>https://medium.com/@samil.mehdiyev/elk-stack-on-windows-server-part-3-customization-3ef334906f4d?source=rss-9de398fdedd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ef334906f4d</guid>
            <category><![CDATA[elk-stack]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[logstash]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[kibana]]></category>
            <dc:creator><![CDATA[Shamil Mehdiyev]]></dc:creator>
            <pubDate>Sun, 30 Sep 2018 17:53:17 GMT</pubDate>
            <atom:updated>2022-03-10T10:31:26.281Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*bA3wR83VXP3STB5KWz_L1w.png" /></figure><p>In this post, I will try to explain how to customize “Logstash” so that, it should be able to read and filter your custom log files and you could visualize them in “Kibana”. In <a href="https://medium.com/@samil.mehdiyev/elk-stack-on-windows-server-part-1-introduction-e187e7fa34d2">part 1</a>, I was mentioned that, “Logstash” has 3 stages. <br>They are:</p><p>1) Input Plugin<br> 2) Filter Plugin<br> 3) Output Plugin</p><p>Also, I mentioned that, inside “Input Plugin” we can use different type of input plugins. For example: file, beats, http and etc. And in <a href="https://medium.com/@samil.mehdiyev/elk-stack-on-windows-server-part-2-installation-d2a7200b65a6">part 2</a>, I was showing briefly how to use beats so that, they visualized different Windows logs and packet logs via “winlogbeat” and “packetbeat” respectively.</p><p>You can ask the question “Why we customize “Logstash” for reading log files if we have a filebeat log shipper which shipping different kinds of logs into the ELK Stack?”</p><p>Let me answer. Of course, It isn’t necessary to customize “Logstash” and you can use filebeat input instead of file input. But, take under consideration the following points:</p><ol><li>Filebeat comes with internal modules (Apache, NGINX, MySQL, and etc.) that simplify the collection, parsing, and visualization of common log formats down to a single command. So, if you use log files which generated by one of them, it is enough to use filebeat input plugin. And as a result, you could able to visualize your data as you want.</li><li><strong>Filebeat DO NOT FILTERING</strong>. It means, if your log file (ex: Apache) contains any specific content, which you need to parameterize, simply you can’t be able to filter it.</li><li>If you log file contains specific content, which you want to parameterize them, I will recommend you use “file” input plugin. Logstash will go through your custom filter plugin and will be able to add your parameters as fields, so that in “Kibana” you will be able to search or visualize them as you want.</li></ol><p>Let’s START.</p><p><strong>FIRST STEP</strong>: Change Logstash “Input” plugin.</p><p>If you remember from part 2, our “logstash.json” looks as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*OEZytCehTKsZ_ySHeXhJJA.png" /><figcaption>“logstash.json”</figcaption></figure><p>Add “file” input plugin, instead of bean (you can comment it or simply delete it).</p><blockquote>file {<br> type =&gt; “mylog”<br> path =&gt; “C:/programdata/elasticsearch/custom-logs-dir/custom-*.log”<br> mode =&gt; “tail”<br> start_position =&gt; “beginning”<br>}</blockquote><p>Here, I was defining few parameters like:</p><ul><li>path: From where “Logstash” will be reading log files.</li><li>type: Types are used mainly to filter your different inputs. Add a type field to all events handled by this input.</li><li>mode: What mode do you want the file input to operate in.</li><li>start_position: Choose where Logstash starts initially reading files: at the beginning or at the end. Value can be: [beginning, end]</li></ul><p><strong>SECOND STEP</strong>: View custom log file.</p><p>Let’s check our custom log file (you can download by <a href="https://github.com/SamilMehdiyev/elkstask/blob/master/custom-test-log.log">this link</a>) and copy this file to a directory which was defined above, which we set to “path” parameter (in “input plugin”). My log file named as “custom-text-log.log”. So, it will be acceptable under pattern “custom-*.log”. My log file looks like as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*QsduIoxWNnQBdIf95TU9wg.png" /><figcaption>log file</figcaption></figure><p>Each line has the following structure (separated by “\t”):</p><p>* Date<br> * Time<br> * Message<br> * Argument 1<br> * Argument 2<br> * Math operation<br> * Rest parameters (only in one case)</p><p>So, in the next step we will use filter plugin. We will do different operations like: (check some condition, set patterns, add fields with specific values and etc.).</p><p><strong>THIRD STEP</strong>: Configure “filter” plugin.</p><p>Let’s first see how updated “logstash.json” file looks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yRyspedBd55YyrbSOrMy3g.png" /><figcaption>“logstash.json” file</figcaption></figure><p>We have “input plugin” (which will be reading files from defined path), “filter plugin” (which will be filter our custom logs) and “output plugin” (which will be send filtered information to the destination, in this case elasticsearch). Here we will discuss about “filter plugin” in more detail.</p><p>1) In filter block, first what we see is main if condition:</p><blockquote>if ([type] == “mylog”) {<br> …<br>}</blockquote><p>Input plugin can read data from many sources and we can set arbitrary name for distinct each of them. In our case, it was “mylog”. So, in the future if we will need to add another input source, we can name it (ex: “yourlog”) and define another filter strategy for this type of logs.</p><p>2) Line 12–20: “Grok” filter plugin.</p><p>From the official documentation: Parse arbitrary text and structure it. Grok is a great way to parse unstructured log data into something structured.</p><p>3) Line 14–18: “match” option.</p><p>Inside “Grok filter” I was using “match” grok filter configuration option. Each line of your log file will be saved as “message” field. “match” option checks message content for each of defined patterns. And if it will be successful, “match” add each information to a specified field. In our case, we have 3 patterns (line 15–17).</p><p>In our case, we have 3 different types of line (below picture), respectively, we will use different patterns for each of them:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*yTCdtdBnYdpZWt_c4sMf1A.png" /><figcaption>piece of content from log file</figcaption></figure><p><strong>Line 15</strong>: Let’s open each part of this pattern.</p><blockquote>(?&lt;DateTime&gt;%{MONTHDAY}-%{MONTH}-%{YEAR} %{TIME} %{WORD})</blockquote><p>A pattern defined in brackets, will be considered as one field. We set to the field name (“DateTime”) inside “&lt;” and “&gt;”. And after “&gt;”, we will define field pattern. For detailed information about grok patterns, you can read from the documentation (link mentioned in “References” part).</p><blockquote>(?&lt;Message&gt;%{WORD} %{WORD} %{WORD})</blockquote><p>Again, I use brackets to define few information under one field and this time I was name it as “Message”. This pattern will be catching every line, which will be having 3 words separated by “space” (in our case, “one more message”).</p><blockquote>%{NUMBER:Arg1}</blockquote><p>After “Message” data, pattern took a number (in this case, 59) and set it to the field which I defined as “Arg1”.</p><blockquote>%{NUMBER:Arg2}</blockquote><p>After “Arg1” data, pattern took a number (in this case, 51) and set it to the field which I defined as “Arg2”.</p><blockquote>%{WORD:Operation}</blockquote><p>After “Arg2” data, pattern took string information (ex: “multiplication”) and set it to the field which I defined as “Operation”.</p><blockquote>%{GREEDYDATA:params}</blockquote><p>“GREEDYDATA” used for getting rest of the information. In our case, after “multiplication” word in log file, I was getting rest of string (by “GREEDYDATA”) and set it to field named as “params”.</p><p><strong>Line 16</strong>: Have the same structure and fields, but with the following difference:</p><blockquote>(?&lt;Message&gt;%{WORD} %{WORD})</blockquote><p>Instead of 3 words, I was getting messages with 2 words (in our case, “another message”). Also, we didn’t use “GREEDYDATA” in this case.</p><p><strong>Line 17</strong>: Have the same structure and fields, but with the following difference:</p><blockquote>(?&lt;Message&gt;%{WORD})</blockquote><p>Instead of 2 or 3 words, I was getting messages with only one word (in our case, “custommessage”). Here also, we didn’t use “GREEDYDATA” in this case.</p><p>4) Line 22–44: if conditions for patterns.</p><p>In this block, I was checking “Message” field to define which code block will be working (line 22, 28 and 40). And each of them do different operations:</p><p><strong>Line 22</strong>: If “Message” field will be having value “custommessage”, then the 1st block will be working (line 22–26).</p><p>In this block, I was simply adding new field named as “NewField” and set the value “Hello”. And for adding a new field, I was using “add_field” option inside “mutate” filter plugin (you can read about “mutate” and another filter plugin from documentation, link mentioned in “References” part).</p><p><strong>Line 28</strong>: If “Message” field will be having value “another message”, then the 2nd block will be working (line 28–38).</p><p>In this block, I was using “mutate” plugin. But before adding a new field, I was using another filter plugin (“split”). This plugin will be split “Message” field (as separator, defined “space”) and add each element of array as new fields.</p><p><strong>Line 40:</strong> If “Message” field will be having value “one more message”, then the 3rd block will be working (line 40–44). In this block, I was using another “grok” plugin and match “params” field, which was defined in line 15 at the end of pattern (“%{GREEDYDATA:params}”)</p><p><strong>Line 44:</strong> In this line, I was using another “mutate” plugin. In this case, it removes “params” field, because at result, we will not use this field. And we will not use it in Kibana.</p><p><strong>FORTH STEP</strong>: Save &amp; Restart.</p><p>Before starting working with “Kibana”, let’s save configuration file and restart “Logstash” service. Let’s go through few notes:</p><ol><li>After restarting services, you can check elasticsearch indices by the following link: <a href="http://127.0.0.1:9200/_cat/indices?v&amp;pretty">http://127.0.0.1:9200/_cat/indices?v&amp;pretty</a>. By this link, you will be able to see which indices created and can check other information (index, status, uuid and etc.).</li><li>If you didn’t find an index, which you define in this list, please check “Logstash” log file. Maybe something went wrong. Log file path will be “C:\ELK\logstash\logs\logstash-plain.log” (in my case).</li></ol><p>Cheers, it is a FINISH. Now, you can open “Discover” menu in “Kibana” and see your result. In my case, it looks like as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pkqMr-K8AqTJqdXtbxXF6A.png" /><figcaption>Kibana, Discover menu</figcaption></figure><p>And now you will be able to filter your logs and visualize them as you want. One example I can show you:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MklxnKrFgHldpNyn5Kj7_A.png" /><figcaption>Kibana, Visualize menu</figcaption></figure><p><strong>Conclusion</strong></p><p>That’s the end. Thank you for your time. I hope, this part will help you to better understand the process of transformation of custom logs. Please feel free to share with me your comments and feedback.</p><p>If you like :) <a href="https://www.buymeacoffee.com/shmehdiyev">https://www.buymeacoffee.com/shmehdiyev</a></p><p><strong>References</strong>:</p><p><a href="http://sysadvent.blogspot.com/2016/12/day-12-logstash-fundamentals.html">1) http://sysadvent.blogspot.com/2016/12/day-12-logstash-fundamentals.html</a><br>2) <a href="https://logz.io/blog/filebeat-tutorial/">https://logz.io/blog/filebeat-tutorial/</a><br>3) <a href="https://www.elastic.co/guide/en/logstash/current/plugins-inputs-file.html">File input plugin (documentation)</a><br>4) <a href="http://grokdebug.herokuapp.com/patterns#">Grok Patterns</a><br>5) <a href="https://www.elastic.co/guide/en/logstash/current/filter-plugins.html">Filter plugin</a><br>6) <a href="http://grokdebug.herokuapp.com/">Grok Debugger</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ef334906f4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ELK STACK ON WINDOWS SERVER — PART 2 — INSTALLATION]]></title>
            <link>https://medium.com/@samil.mehdiyev/elk-stack-on-windows-server-part-2-installation-d2a7200b65a6?source=rss-9de398fdedd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2a7200b65a6</guid>
            <category><![CDATA[logstash]]></category>
            <category><![CDATA[kibana]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[elk-stack]]></category>
            <dc:creator><![CDATA[Shamil Mehdiyev]]></dc:creator>
            <pubDate>Sun, 30 Sep 2018 17:51:59 GMT</pubDate>
            <atom:updated>2022-03-10T10:31:56.550Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*T91vwLZX8IqcvIG6g3u4Qg.png" /></figure><p>In <a href="https://medium.com/@samil.mehdiyev/elk-stack-on-windows-server-part-1-introduction-e187e7fa34d2">Part 1</a>, we spoke about ELK Stack commonly. In this post, we will go through the ELK Stack installation process on Windows Server 2012 R2 platform. We will go step-by-step through the installation process with a brief description of each step.</p><p>Let’s take a look to our checklist. What we need?</p><p>1) Windows Server 2012 R2 <br>2) Elasticsearch (<a href="https://www.elastic.co/downloads">https://www.elastic.co/downloads</a>)<br>3) Logstash (<a href="https://www.elastic.co/downloads">https://www.elastic.co/downloads</a>)<br>4) Kibana (<a href="https://www.elastic.co/downloads">https://www.elastic.co/downloads</a>)<br>5) The Non-Sucking Service Manager (NSSM) (<a href="https://nssm.cc/">https://nssm.cc</a>)<br>6) Java (version 8) (<a href="https://www.java.com/">https://www.java.com/</a>)<br>7) WinPcap (<a href="https://www.winpcap.org/">https://www.winpcap.org/</a>)</p><p>Also for demonstration, we will need following log shippers:</p><p>1) Filebeat (<a href="https://www.elastic.co/downloads">https://www.elastic.co/downloads</a>)<br>2) Packetbeat (<a href="https://www.elastic.co/downloads">https://www.elastic.co/downloads</a>)<br>3) Winlogbeat (<a href="https://www.elastic.co/downloads">https://www.elastic.co/downloads</a>)</p><p>Before starting, let me share with you some notes:</p><ul><li>I’ll be using a Windows 2012 R2 VM with 4 vCPUs, 8 Gb RAM. For testing, it will be comfortable if you have min 35–40 Gb free space.</li><li>I will be recommending you to download the same version of all components (Elasticsearch, Logstash, Kibana and beats). Of course, you can mix different version of particular components, but this may result in failure. Anyway, it is totally up to you.</li><li>I will use version 6.4.0, but you can use the latest release.</li><li>I also recommend unzipping all of the components (zips, including the beats agents) to a common local directory that will be home for the installs — For example: “C:\ELK\”. Again, it’s totally up to you, so if you don’t like name please feel free to change what you want.</li></ul><p>Let’s START.</p><p>After we download all components and unzipping, probably you will have the same look:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*mTbrClo2ZKstjmIwNxrBLQ.png" /><figcaption>ELK Stack home directory</figcaption></figure><p><strong>FIRST STEP</strong>: Installation of Java JDK. The first step we will do is installing the latest version of the Java JDK and create the JAVA_HOME system variable.</p><p><strong>1.</strong> Install the Java JDK and copy the installation directory (for me, it will be: “C:\Program Files\Java\jre1.8.0_181\”). In your case, it may be another number after “_” (underscore).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*khWhtqxeu7HbFEu32d-ZVg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*967zMQPihFicFUpTyxMKuA.png" /><figcaption>Installation of JDK</figcaption></figure><p><strong>2.</strong> Open “System Properties” -&gt; “Environment Variables” and create a new “System variable” named as JAVA_HOME with a value of the path from the Java install.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*KJCx1-MFylvVn7Qd1KsPRg.png" /><figcaption>Add new “System variable”</figcaption></figure><p><strong>SECOND STEP</strong>: Installing Elasticsearch.</p><p>1) To install Elasticsearch open a Windows PowerShell prompt (Run as Administrator) and type the following commands:</p><blockquote>Invoke-Expression -command “c:\ELK\elasticsearch\bin\elasticsearch-service install”</blockquote><p>If installation finish successfully, PowerShell should display something similar:</p><p><em>Installing service: “elasticsearch-service-x64”<br>Using JAVA_HOME (64-bit): “C:\Program Files\Java\jdk1.8.0_181\”<br>The service ‘elasticsearch-service-x64’ has been installed.</em></p><p>2) After Elasticsearch installed, open the Elasticsearch service properties with below command, change Startup type to <strong>Automatic</strong> and start the service.</p><blockquote>Invoke-Expression -command “c:\ELK\elasticsearch\bin\elasticsearch-service manager”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*u6uljTW6VvUwV14wm2nL0w.png" /></figure><p>3) At last, let’s verify that the Elasticsearch is running. Open a browser (it may any browser, but let’s use Google Chrome) and go to <a href="http://127.0.0.1:9200/"><strong>http://127.0.0.1:9200</strong></a>. And if you see similar to the following, congrats Elasticsearch works and we can move to the next step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*0985JYwrfRBDOoxkSXEjHA.png" /><figcaption>Elasticsearch</figcaption></figure><p><strong>THIRD STEP</strong>: Installing Logstash.</p><p>1) Before installing Logstash, you will need to create a “logstash.json” configuration file in the bin folder inside an unzipped Logstash folder. (in my case: C:\ELK\logstash\bin\)</p><p>For now, let’s create a file and fill the configuration details in the json file. You can copy content from <a href="https://github.com/SamilMehdiyev/elkstask/blob/master/logstash.json">this link</a>.</p><p>2) To install Logstash open a Windows PowerShell prompt (Run as Administrator) and type the following commands. We will use NSSM (Non-Sucking Service Manager) to install it as a Windows Service:</p><p>a. Run following command:</p><blockquote>Invoke-Expression -command “c:\ELK\nssm\win64\nssm install Logstash”</blockquote><p>b. In Application Tab, set the following settings:</p><ul><li>Path: C:\ELK\logstash\bin\logstash.bat</li><li>Startup directory: C:\ELK\logstash\bin</li><li>Arguments: -f C:\ELK\logstash\config\logstash.conf</li></ul><p>c. In Details Tab, set the following:</p><ul><li>Display Name: Logstash</li><li>Description: Logstash Service</li><li>Startup type: Automatic</li></ul><p>d. In Dependencies Tab, set the following:</p><ul><li>This service depends……: elasticsearch-service-x64</li></ul><p>e. After successfully installing, run following command:</p><blockquote>Invoke-Expression –command “C:\ELK\logstash\bin\logstash-plugin install logstash-input-beats”</blockquote><p>Next I was providing screenshots, which help to better understand above points:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*n_92ktk_ySJMRfsGJlA1cQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*G9vKqnBfx4IHbpS_atAFZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*3G_r6Eq3PbIBfAKiLoDAaA.png" /><figcaption>Logstash installing process</figcaption></figure><p>At last, click “Install Service”. And if you see &lt;&lt; Service “Logstash” installed successfully! &gt;&gt;, congrats Logstash works and we can move to the next step.</p><p><strong>FORTH STEP</strong>: Installing Kibana.</p><p>To install Kibana open a Windows PowerShell prompt (Run as Administrator) and type the following command. We will use again NSSM (Non-Sucking Service Manager) to install it as a Windows Service:</p><p>a. Run following command:</p><blockquote>Invoke-Expression -command “c:\ELK\nssm\win64\nssm install Kibana”</blockquote><p>a. In Application Tab, set the following settings:</p><ul><li>Path: C:\ELK\kibana\bin\kibana.bat</li><li>Startup directory: C:\ELK\kibana\bin</li><li>Arguments: “In this case, we DIDN’T SET ANY ARGUMENT. Let it be empty”</li></ul><p>b. In Details Tab, set the following:</p><ul><li>Display Name: Kibana</li><li>Description: Kibana Service</li><li>Startup type: Automatic</li></ul><p>c. In Dependencies Tab, set the following:</p><ul><li>This service depends……:<br>elasticsearch-service-x64<br>Logstash</li></ul><p><strong>Note</strong>: <em>Be careful, here we need to set 2 services as dependencies. Write each of them in new line.</em></p><p>Next I was providing screenshots, which help to better understand above points:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*2FKWBNJzIhqyODCQUv5Rrg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*GZEL1bJF_OIM9HmCHLoI4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*rfb0lKamdsKtSMhNc4kh8g.png" /><figcaption>Kibana installing process</figcaption></figure><p>Again at last, click “Install Service”. And if you see &lt;&lt; Service “Kibana” installed successfully! &gt;&gt;, we successfully install Kibana and we can move to the next step.</p><p>Before moving to the next step, let’s verify the services are started. To do this, open “Run” (Windows + R) and type “services.msc”. In open windows find the following services and check “Status” each of them:</p><p>Elasticsearch<br>Logstash<br>Kibana</p><p>And open a browser and go to <a href="http://localhost:5601/">http://localhost:5601</a> (or <a href="http://127.0.0.1:5601/">http://127.0.0.1:5601</a>) — you should see similar to the following screenshot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c6CtLKThKRLV8T4z68XRHg.png" /><figcaption>Kibana interface (Management)</figcaption></figure><p><strong>FIFTH STEP</strong>: Installing Beats.</p><p>Before starting the installation process, let me tell you that in this documentation I didn’t explain deeply about beats. I will give brief information about beats, but we will discuss about this topic deeply at another time.</p><p><strong>What are Beats?</strong></p><p>The beats are a collection of lightweight (resource-efficient, no dependencies, small) and open-source log shippers installed on servers for data collection, so that it can be indexed and analyzed via the ELK Stack.</p><ul><li><strong>Packetbeat</strong> — Packetbeat captures network traffic between servers and, as such, can be used for application and performance monitoring.</li><li><strong>Filebeat</strong> — Filebeat, as its name implies, is used for collecting and shipping log files.</li><li><strong>Winlogbeat</strong> — It is a beat designed specifically for collecting Windows Event logs. It can be used to analyze security events, updates installed, and so forth.</li></ul><p>Now to install beats, open a Windows PowerShell prompt (Run as Administrator) and type the following commands:</p><p>a. Installing Filebeat:</p><blockquote>PowerShell.exe -ExecutionPolicy UnRestricted -File C:\ELK\filebeat\.\install-service-filebeat.ps1</blockquote><p>b. Installing WinPcap:</p><blockquote>c:\ELK\WinPcap_4_1_3.exe</blockquote><p>c. Installing Packetbeat:</p><blockquote>PowerShell.exe -ExecutionPolicy UnRestricted -File C:\ELK\packetbeat\.\install-service-packetbeat.ps1</blockquote><p>d. Installing Winlogbeat:</p><blockquote>PowerShell.exe -ExecutionPolicy UnRestricted -File C:\ELK\winlogbeat\.\install-service-winlogbeat.ps1</blockquote><p>At last, let’s verify the services are started. To do this, open “Run” (Windows + R) and type “services.msc”. In open windows find the following services and check “Status” each of them:</p><p>filebeat<br>packetbeat<br>winlogbeat</p><p><strong>SIXTH STEP</strong>: Visualizing Beats.</p><p>Now we will go back into Kibana and under “Management” -&gt; “Kibana” -&gt; “Index Patterns” configure the following index patterns:</p><p>1) filebeat-*<br> 2) packetbeat-*<br> 3) winlogbeat-*</p><p>And cheers, if you see screens like below, let me congratulate you. You install ELK Stack successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YXmYpoxL43kG5NwR5LUC4A.png" /><figcaption>Management tab</figcaption></figure><p>And under “Discover” we will see magic :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HuvmrHnOQ-LUCeCOY_kCWg.png" /><figcaption>Discover tab</figcaption></figure><p><strong>Conclusion</strong></p><p>I hope, this post was useful for you. Please feel free to share with me your comments and feedback.</p><p>In Part 3, you can find the customization process of “Logstash” and visualization it in Kibana.</p><p>If you like :) <a href="https://www.buymeacoffee.com/shmehdiyev">https://www.buymeacoffee.com/shmehdiyev</a></p><p><strong>References</strong>:</p><p>1) <a href="https://www.youtube.com/watch?v=f_cAbYyuL-c">Installing Elasticsearch, Logstash and Kibana on Windows Server 2012 R2 2016 by Rob Willis</a> (Thanks to Rob Willis, his video tutorial and blog material help me to better understand the whole process)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2a7200b65a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ELK STACK ON WINDOWS SERVER — PART 1 — INTRODUCTION]]></title>
            <link>https://medium.com/@samil.mehdiyev/elk-stack-on-windows-server-part-1-introduction-e187e7fa34d2?source=rss-9de398fdedd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e187e7fa34d2</guid>
            <category><![CDATA[elk-stack]]></category>
            <category><![CDATA[logstash]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[kibana]]></category>
            <dc:creator><![CDATA[Shamil Mehdiyev]]></dc:creator>
            <pubDate>Sun, 30 Sep 2018 17:50:14 GMT</pubDate>
            <atom:updated>2018-09-30T17:50:14.809Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*bA3wR83VXP3STB5KWz_L1w.png" /></figure><p>From day-to-day world of digital content increase with geometric progress. And try to read, find or analyze any information became difficult and time consumed. You need to spend a huge amount of time to process some needed information. To solve this problem, some good guys (thanks to their passion) developed definitions like search engine, which is designed to help to decrease the time required to find information and the amount of information which must be consulted.</p><p>So, In this post, we will try to understand the ELK Stack (in another word, Elastic Stack) — Log Management Platform, which use the most popular search engine “Elasticsearch”. I was breaking up explanation in 3 parts. They are:</p><p>1) Introduction — What is the ELK Stack?<br> 2) Installation — Install ELK Stack on Windows Server 2012 R2<br> 3) Customization — Customize and visualize custom logs</p><p><strong>What is the ELK Stack?</strong></p><p>The ELK Stack is a collection of three open-source products — Elasticsearch, Logstash, and Kibana. The whole process can be visualizing as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i5ImbSff4JwsxBIEf9WXdw.png" /><figcaption>Whole process of ELK Stack</figcaption></figure><p><strong>Elasticsearch</strong></p><p>Elasticsearch is a distributed, RESTful search and analytics engine (which is based on Apache Lucene) capable of solving a growing number of use cases. Elasticsearch is developed in Java and is released as open source under the terms of the Apache License and categorized as a NoSQL database. Which means, it stores data in an unstructured way.</p><p>According to the DB-Engines ranking, Elasticsearch is the most popular enterprise search engine followed by Apache Solr (also based on Apache Lucene).</p><p>In the context of data analysis, Elasticsearch is used together with the other components in the ELK Stack, Logstash and Kibana, and plays the role of data indexing and storage.</p><p><strong>Logstash</strong></p><p>Logstash is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to your favorite “stash.” (ex: Elasticsearch)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GJVNFUct-EvjiqOBuScBkQ.png" /><figcaption>Logstash</figcaption></figure><p>Logstash is a log pipeline tool, which has 3 stages:</p><p>1) Input Plugins — Accepts inputs from various sources<br> 2) Filter Plugins — Executes different transformations<br> 3) Output Plugins — Exports the data to various targets</p><p><strong>Input Plugins</strong>: Logstash supports a variety of inputs that pull in events from a multitude of common sources, all at the same time. Input plugin examples: file, http, beats, log4j and etc. Check the documentation for full list of <a href="https://www.elastic.co/guide/en/logstash/current/input-plugins.html">Input Plugins</a>.</p><p><strong>Filter Plugins</strong>: As data travels from source to store, Logstash filters parse each event, identify named fields to build a structure, and transform them to converge on a common format for easier, accelerated analysis and business value.</p><p>A filter plugin performs intermediary processing on an event. Filters are often applied conditionally depending on the characteristics of the event. The most commonly used filter plugins, which I used during working process are the following (check documentation for all possible <a href="https://www.elastic.co/guide/en/logstash/current/filter-plugins.html">Filter Plugins</a>):</p><p>1) grok — Parses unstructured event data into fields<br> 2) mutate — Performs mutations on fields<br> 3) kv — Parses key-value pairs</p><p><strong>Output Plugins</strong>: Logstash has a variety of outputs that let you route data where you want. In our case it will be Elasticsearch, but it can be also file, email, http and etc. You can check list of all possible <a href="https://www.elastic.co/guide/en/logstash/current/output-plugins.html">Output Plugins</a> from the documentation.</p><p><strong>Kibana</strong></p><p>The last component of ELK stack is Kibana. Kibana is the ‘K’ in the ELK Stack, the world’s most popular open source log analysis platform. It provides users with a tool for exploring, visualizing, and building dashboards on top of the log data stored in Elasticsearch clusters. Kibana makes it easy to understand large volumes of data.</p><p>It is simple, browser-based interface enables you to quickly create and share dynamic dashboards that display changes to Elasticsearch queries in real time. Kibana’s visualization features allow users to visualize data in a variety of different ways, using charts, tables, geographical maps and other types of visualizations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rEYnHEQOHna7UwvGtNk_JQ.jpeg" /><figcaption>Kibana (example)</figcaption></figure><p><strong>Conclusion</strong></p><p>I hope I was help you to understand What is the ELK Stack? Please feel free to share with me your comments and feedback.</p><p>In Part 2, you can find the installation process of ELK Stack on Windows Server 2012 R2 platform.</p><p><strong>References</strong>:</p><p>1) <a href="https://en.wikipedia.org/wiki/Elasticsearch">Elasticsearch (wiki)</a><br>2) <a href="https://www.elastic.co/products/elasticsearch">Elasticsearch</a><br>3) <a href="https://www.elastic.co/products/kibana">Kibana</a><br>4) <a href="https://www.elastic.co/products/logstash">Logstash</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e187e7fa34d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>