<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Minhaz</title>
    <description>The latest articles on DEV Community by Minhaz (@minhaz1217).</description>
    <link>https://dev.to/minhaz1217</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1240109%2Fbe2b9b96-6ba3-4140-88f9-d36ee373bf9a.jpg</url>
      <title>DEV Community: Minhaz</title>
      <link>https://dev.to/minhaz1217</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/minhaz1217"/>
    <language>en</language>
    <item>
      <title>Java Spring Boot use Seq for logging</title>
      <dc:creator>Minhaz</dc:creator>
      <pubDate>Mon, 21 Oct 2024 21:32:46 +0000</pubDate>
      <link>https://dev.to/minhaz1217/java-spring-boot-use-seq-for-logging-39fm</link>
      <guid>https://dev.to/minhaz1217/java-spring-boot-use-seq-for-logging-39fm</guid>
      <description>&lt;p&gt;The primary motivation is that I use SEQ for logging, but I couldn't find a quick complete guide to use SEQ with java spring boot using gradle. So here I'm documenting my findings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps
&lt;/h2&gt;

&lt;h4&gt;
  
  
  I'm using this configuration for the project
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxgar86w88jgfup8suwe7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxgar86w88jgfup8suwe7.png" alt="Project setup" width="800" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Add these to &lt;code&gt;build.gradle&lt;/code&gt; for dependency
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;repositories {
    ...
    maven { url 'https://jitpack.io' }
}

dependencies {
    ...
    implementation 'com.github.serilogj:serilogj:v0.6.1'
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Now just configure the logger
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// import serilogj.Log;
// import serilogj.LoggerConfiguration;
// import serilogj.events.LogEventLevel;
// import static serilogj.sinks.seq.SeqSinkConfigurator.seq;

// setting up the logger
Log.setLogger(new LoggerConfiguration()
        .writeTo(seq("http://localhost:5341/"))
        .setMinimumLevel(LogEventLevel.Verbose)
        .createLogger());

// using the logger
var logger = Log.getLogger().forContext(SpringApplication.class);
logger.information("Hello World");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this setup the logger should work&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzbrqpyqfjda8aqrgu25s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzbrqpyqfjda8aqrgu25s.png" alt="SEQ Working" width="800" height="87"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can find the code &lt;a href="https://github.com/minhaz1217/java-quarkus/tree/master/spring-boot-seq" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Reference
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://docs.datalust.co/docs/using-java" rel="noopener noreferrer"&gt;https://docs.datalust.co/docs/using-java&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/minhaz1217/devops-notes/tree/master/79.%20java%20spring%20boot%20use%20seq%20for%20logging" rel="noopener noreferrer"&gt;My blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/minhaz1217/java-quarkus/tree/master/spring-boot-seq" rel="noopener noreferrer"&gt;Source Code&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>seq</category>
      <category>logging</category>
    </item>
    <item>
      <title>Java Spring Boot use log4j in a gradle project</title>
      <dc:creator>Minhaz</dc:creator>
      <pubDate>Fri, 18 Oct 2024 20:27:21 +0000</pubDate>
      <link>https://dev.to/minhaz1217/java-spring-boot-use-log4j-in-a-gradle-project-54kg</link>
      <guid>https://dev.to/minhaz1217/java-spring-boot-use-log4j-in-a-gradle-project-54kg</guid>
      <description>&lt;p&gt;The motivation here is that I've spent just too much time trying to figure out how to add logging with log4j in spring boot in &lt;strong&gt;gradle&lt;/strong&gt;. Here the gradle part was the one giving me the most grief because all the documentations I could find was for maven.&lt;/p&gt;

&lt;p&gt;So I'm documenting my findings here so that next person who is looking for this might find my post and will be able to figure it out quickly.&lt;/p&gt;

&lt;h3&gt;
  
  
  This is the configuration I'm using for the demo. I've tested the same implementation in java 17 as well.
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3lr68j2kdkv8i0hnbxy5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3lr68j2kdkv8i0hnbxy5.png" alt="Project setup" width="800" height="468"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Add this line to the &lt;code&gt;build.gradle&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;configurations {
    all*.exclude module : 'spring-boot-starter-logging'
}

dependencies {
    ...
    implementation "org.springframework.boot:spring-boot-starter-log4j2"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create a file named &lt;code&gt;log4j2.xml&lt;/code&gt; in the &lt;code&gt;src/main/resources&lt;/code&gt; folder and add this to the file
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;Configuration status="INFO"&amp;gt;
    &amp;lt;Appenders&amp;gt;
        &amp;lt;Console name="console" target="SYSTEM_OUT"&amp;gt;
            &amp;lt;PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - Message: %msg%n"/&amp;gt;
        &amp;lt;/Console&amp;gt;
    &amp;lt;/Appenders&amp;gt;
    &amp;lt;Loggers&amp;gt;
        &amp;lt;Root level="trace"&amp;gt;
            &amp;lt;AppenderRef ref="console"/&amp;gt;
        &amp;lt;/Root&amp;gt;
    &amp;lt;/Loggers&amp;gt;
&amp;lt;/Configuration&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your setup is done, now you can add logger from log4j and it will use this xml configuration. Notice that I've added a &lt;code&gt;Message:&lt;/code&gt; in every message. So if you don't want it, you can just remove it. I've added it there so that I can test whether or not the project was using this xml file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Now to test you can just use the log4j logger. You can add it in the &lt;code&gt;main&lt;/code&gt; method.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// import org.apache.logging.log4j.LogManager;
// import org.apache.logging.log4j.Logger;

Logger logger = LogManager.getLogger(SpringApplication.class);
logger.info("Hello World!");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The logger setup should work as expected. Notice the &lt;code&gt;Message:&lt;/code&gt; part.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzamgeg46iaqa3lz8llya.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzamgeg46iaqa3lz8llya.png" alt="Logging working" width="800" height="74"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can find the project &lt;a href="https://github.com/minhaz1217/java-quarkus/tree/master/spring-boot-log4j" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;(&lt;a href="https://www.sentinelone.com/blog/started-quickly-spring-boot-logging/)%5Bhttps://www.sentinelone.com/blog/started-quickly-spring-boot-logging/%5D" rel="noopener noreferrer"&gt;https://www.sentinelone.com/blog/started-quickly-spring-boot-logging/)[https://www.sentinelone.com/blog/started-quickly-spring-boot-logging/]&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;(&lt;a href="https://github.com/minhaz1217/devops-notes/tree/master/78.%20java%20spring%20boot%20use%20log4j%20in%20a%20gradle%20project)%5Bhttps://github.com/minhaz1217/devops-notes/tree/master/78.%20java%20spring%20boot%20use%20log4j%20in%20a%20gradle%20project%5D" rel="noopener noreferrer"&gt;https://github.com/minhaz1217/devops-notes/tree/master/78.%20java%20spring%20boot%20use%20log4j%20in%20a%20gradle%20project)[https://github.com/minhaz1217/devops-notes/tree/master/78.%20java%20spring%20boot%20use%20log4j%20in%20a%20gradle%20project]&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/minhaz1217/java-quarkus/tree/master/spring-boot-log4j" rel="noopener noreferrer"&gt;The dummy project&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>javascript</category>
      <category>java</category>
      <category>springboot</category>
      <category>log4j</category>
    </item>
    <item>
      <title>Reset password in uptime kuma</title>
      <dc:creator>Minhaz</dc:creator>
      <pubDate>Thu, 17 Oct 2024 19:14:10 +0000</pubDate>
      <link>https://dev.to/minhaz1217/reset-password-in-uptime-kuma-1bdn</link>
      <guid>https://dev.to/minhaz1217/reset-password-in-uptime-kuma-1bdn</guid>
      <description>&lt;p&gt;The purpose of this is to reset the password of an uptime kuma installation. The motivation behind this is that I forget my password for the uptime kuma very frequently. So I need to reset them every 4-6 months (⓿_⓿).&lt;/p&gt;

&lt;p&gt;So I'm just documenting the flow here for anyone that needs it.&lt;/p&gt;

&lt;h3&gt;
  
  
  if you are running the uptime kuma in a docker, then at first go inside the container
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec -it uptime-kuma bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Install sqlite in the container
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apt install sqlite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Locate the &lt;code&gt;kuma.db&lt;/code&gt; file and open it in sqlite, for my case it is in the &lt;code&gt;/app/data&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sqlite3 /app/data/kuma.db
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  You can list all the users using this query and note the id
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * FROM user;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Run this command to update the password
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UPDATE user SET password="$2y$10$IWoZl5q9Tvvp1wxROvi4hOul7XP.rfyrvm4xbm7ufVANke1nfvLIu" WHERE id=1;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to set a specific password then just go to &lt;a href="https://bcrypt-generator.com/" rel="noopener noreferrer"&gt;this&lt;/a&gt; website and generate the bcrypt password. Then put it inside the sql &lt;code&gt;password="&amp;lt;encrypted_password&amp;gt;"&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Now you can just log in to your user account using the password &lt;code&gt;password&lt;/code&gt;, don't forget to change the password after you log in.
&lt;/h3&gt;

&lt;p&gt;Thanks for reading, let me know if you face any issue (it can be any webdev/devops related issue) and a star on the &lt;a href="https://github.com/minhaz1217/devops-notes" rel="noopener noreferrer"&gt;repo&lt;/a&gt; will be much appreciated :) &lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://docs.pikapods.com/apps/uptime-kuma" rel="noopener noreferrer"&gt;https://docs.pikapods.com/apps/uptime-kuma&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/minhaz1217/devops-notes/tree/master/77.%20reset%20password%20in%20uptime%20kuma" rel="noopener noreferrer"&gt;https://github.com/minhaz1217/devops-notes/tree/master/77.%20reset%20password%20in%20uptime%20kuma&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>devops</category>
      <category>uptimekuma</category>
      <category>webdev</category>
      <category>security</category>
    </item>
    <item>
      <title>How to enable mongodb query logging in reactive java for quarkus with panache</title>
      <dc:creator>Minhaz</dc:creator>
      <pubDate>Sun, 07 Jul 2024 19:51:55 +0000</pubDate>
      <link>https://dev.to/minhaz1217/how-to-enable-mongodb-query-logging-in-reactive-java-for-quarkus-with-panache-22pa</link>
      <guid>https://dev.to/minhaz1217/how-to-enable-mongodb-query-logging-in-reactive-java-for-quarkus-with-panache-22pa</guid>
      <description>&lt;p&gt;Keeping it here so that anyone after me can find these configs easily.&lt;/p&gt;

&lt;p&gt;At my job I've been writing a microservice with java with reactive style. I'm also using mongodb with panache. Recently I had a problem where one of my queries were working perfectly from mongo compass but with panache it wasn't working as expected. So I needed to see the query that panache was generating.&lt;/p&gt;

&lt;p&gt;The quarkus's official document provides a &lt;a href="https://quarkus.io/guides/mongodb-panache#query-debugging" rel="noopener noreferrer"&gt;way&lt;/a&gt; to log mongodb query in output. Unfortunately it only works for non reactive java and the guide doesn't properly mention this.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

quarkus.log.category."io.quarkus.mongodb.panache.common.runtime".level=DEBUG


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;At first I thought for some reason maybe my project configuration was wrong or maybe configs were conflicting and that's why it wasn't showing the logs. I never thought what reactive coding was the problem. So I debugged the issue in other ways and found the proper solution for my problem.&lt;/p&gt;

&lt;p&gt;After that I got somewhat bothered and kept asking myself why the query logging wasn't working and got frustrated. Then in an eureka moment I looked at the configuration key carefully and I can clearly see that the log was enabling a category &lt;code&gt;io.quarkus.mongodb.panache.common.runtime&lt;/code&gt; so I went looking for that package. From my jetbrains IDE I found it and I can clearly see that there is a &lt;code&gt;common.runtime.CommonPanacheQueryImpl&lt;/code&gt; and another &lt;code&gt;common.reactive.runtime.CommonReactivePanacheQueryImpl&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmqk5kbw1sk21nns3npjc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmqk5kbw1sk21nns3npjc.png" alt="Folder structure of the package"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I tried to filter by that category and it worked :) &lt;br&gt;
So the solution is to just enable &lt;code&gt;DEBUG&lt;/code&gt; on this category. So add this line to your application.properties.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

quarkus.log.category."io.quarkus.mongodb.panache.common.reactive.runtime".level=DEBUG


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now the logging is working&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm55zoeuinohgpu274qcq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm55zoeuinohgpu274qcq.png" alt="Query logging working"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Bonus
&lt;/h3&gt;

&lt;p&gt;While searching I've found another way to enable query logging, but it is logging from the mongodb driver. To enable it just add this to the application.properties&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

quarkus.log.category."org.mongodb.driver.protocol.command".level=DEBUG


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The result looks like this, it also outputs the result from the db.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46o537y81psf7ydvnws2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46o537y81psf7ydvnws2.png" alt="MongoDB driver logging"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just thought that I'd post these configs here as a reference to someone who is doing reactive java with panache. As I've invested one of my weekends figuring this out as well as other things. I'll probably make a longer post on my journey as a Senior Software Engineer to debug a panache capability issue and how a junior might navigate these and what were my step by step thought process during this.&lt;/p&gt;

&lt;p&gt;I've learned all these because I kept asking myself "why wouldn't it work?" and it kept bothering me.&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://github.com/minhaz1217/devops-notes/tree/master/72.%20enable%20mongodb%20query%20logging%20in%20panache%20for%20reactive%20java" rel="noopener noreferrer"&gt;My own notes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://quarkus.io/guides/mongodb-panache#query-debugging" rel="noopener noreferrer"&gt;Quarkus docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/quarkusio/quarkus/discussions/24290" rel="noopener noreferrer"&gt;A github discussion&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>java</category>
      <category>mongodb</category>
      <category>quarkus</category>
      <category>panache</category>
    </item>
    <item>
      <title>Quick guide to setting up an shortcut/alias in windows</title>
      <dc:creator>Minhaz</dc:creator>
      <pubDate>Mon, 01 Jul 2024 18:06:54 +0000</pubDate>
      <link>https://dev.to/minhaz1217/quick-guide-to-setting-up-an-shortcutalias-in-windows-g49</link>
      <guid>https://dev.to/minhaz1217/quick-guide-to-setting-up-an-shortcutalias-in-windows-g49</guid>
      <description>&lt;p&gt;This is a quick 30 second guide to setting up an alias in windows. All this is applicable for windows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;The main motivation behind this is that I wanted to simplify the ping command. So that I'll just type a single command and it'll execute the &lt;code&gt;ping www.google.com -t&lt;/code&gt;, which I use to check if my internet connection is stable or not.&lt;br&gt;
The motivation behind this post is that I couldn't find a quick guide/overview to setup alias or terminal shortcuts when I searched google. So hopefully this will be helpful to juniors to get started. &lt;/p&gt;

&lt;p&gt;Open up a powershell and type away.&lt;/p&gt;
&lt;h2&gt;
  
  
  Basic alias by creating simple shortcut.
&lt;/h2&gt;

&lt;p&gt;If you want to just create an alias for a command the script is like this.&lt;br&gt;
If I want to reference the command &lt;code&gt;echo&lt;/code&gt; using a shortcut like &lt;code&gt;ec&lt;/code&gt; the command is like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set-Alias -Name ec -Value echo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the ec command will refer to the echo command, and the echo command is there as well, it didn't go anywhere. To try and see if this works you can try this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ec "Hello World"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6oh6948s2ka06vm160gp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6oh6948s2ka06vm160gp.png" alt="The ec command now is just another command to refer to echo" width="574" height="215"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Little bit extended - call simple commands with shortcut
&lt;/h2&gt;

&lt;p&gt;To create the final alias, I'll have to use a powershell function like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Function PingGoogle { ping www.google.com -t }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here the function's name is &lt;code&gt;PingGoogle&lt;/code&gt; and it executes the &lt;code&gt;ping www.google.com -t&lt;/code&gt; command. We can try it by just entering the &lt;code&gt;PingGoogle&lt;/code&gt; command after pasting the method.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh2h9os598bkygkbcqsw5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh2h9os598bkygkbcqsw5.png" alt="Now I can start a ping by calling this method" width="693" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we'll have to make an alias to this command. Like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set-Alias -Name pingg -Value PingGoogle
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here the &lt;code&gt;pingg&lt;/code&gt; alias is referring to the &lt;code&gt;PingGoogle&lt;/code&gt; function. To test this we can just use &lt;code&gt;pingg&lt;/code&gt; command now.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnx0sna3fabjzbx7fu3ud.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnx0sna3fabjzbx7fu3ud.png" alt="now everytime I type pingg the ping will run" width="700" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus - How to persist these changes.
&lt;/h2&gt;

&lt;p&gt;You'll notice that if you close your terminal then the changes go away, your shortcut won't work.&lt;br&gt;
So to persist these changes across all terminals you'll have to save them in your terminal profile.&lt;/p&gt;

&lt;p&gt;To do that type this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo $profile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will show you the location of your powershell profile file. Go to that location and open that file.&lt;br&gt;
Or open that file with this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;notepad $profile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A file will open in notepad.&lt;/p&gt;

&lt;p&gt;Now paste your code in that notepad and save in the same location. Now what will happen is that every time your terminal runs it will also load codes from this file. That's why your changes that your pasted here will persist between sessions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/set-alias?view=powershell-7.4"&gt;Microsoft Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/minhaz1217/devops-notes/tree/master/71.%20setting%20up%20alias(shortcuts)%20in%20powershell"&gt;My own notes&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>productivity</category>
      <category>automation</category>
      <category>windows</category>
      <category>powershell</category>
    </item>
    <item>
      <title>How to know if you have the XZ vulnerability and what you can do about it</title>
      <dc:creator>Minhaz</dc:creator>
      <pubDate>Tue, 02 Apr 2024 14:12:20 +0000</pubDate>
      <link>https://dev.to/minhaz1217/how-to-know-if-you-have-the-xz-vulnerability-and-what-you-can-do-about-it-41f3</link>
      <guid>https://dev.to/minhaz1217/how-to-know-if-you-have-the-xz-vulnerability-and-what-you-can-do-about-it-41f3</guid>
      <description>&lt;p&gt;If you have been on the internet recently you should already know what happened with the XZ vulnerability. Basically this vulnerability was introduced very recently and not all distros are affected by it.&lt;/p&gt;

&lt;p&gt;Only the versions 5.6.0 and 5.6.1 is affected. So if you aren't using these and you haven't upgraded recently then you are safe.&lt;/p&gt;

&lt;p&gt;If you are ubuntu user this shouldn't affect you as the most recent version of xz available for ubuntu is version 5.4.&lt;/p&gt;

&lt;p&gt;Still I'll document here how to detect and downgrade specific packages if something like this occur.&lt;/p&gt;

&lt;p&gt;So the package that was the problem is the &lt;code&gt;xz-utils&lt;/code&gt; pacakge.&lt;/p&gt;

&lt;p&gt;At first we'll have to which version we are using. &lt;/p&gt;

&lt;p&gt;We can do it using the following commands&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;xz --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apt-cache showpkg xz-utils
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apt-cache policy xz-utils
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the currently used version is &lt;code&gt;5.6.0&lt;/code&gt; or &lt;code&gt;5.6.1&lt;/code&gt; we'll have to downgrade.&lt;/p&gt;

&lt;p&gt;To downgrade first we'll need to know which versions are available.&lt;/p&gt;

&lt;p&gt;We can do that using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apt search xz-utils
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzc28ie2jet68nq76tcoq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzc28ie2jet68nq76tcoq.png" alt="Image description" width="800" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now when we've selected a version to downgrade to we can downgrade using this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install xz-utils=&amp;lt;version&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A sample of this is like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install xz-utils=5.2.5-2ubuntu1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Although not recommended, but if you want to hold automatic upgrade for this package you can do it like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-mark hold xz-utils
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or to revert the hold you can use this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-mark unhold xz-utils
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can follow &lt;a href="https://www.darkreading.com/vulnerabilities-threats/are-you-affected-by-the-backdoor-in-xz-utils"&gt;this&lt;/a&gt; for more specific instructions for other distros.&lt;/p&gt;

</description>
      <category>security</category>
      <category>xz</category>
      <category>backdoor</category>
      <category>linux</category>
    </item>
    <item>
      <title>Instantly preview rendered liquid template</title>
      <dc:creator>Minhaz</dc:creator>
      <pubDate>Wed, 20 Mar 2024 17:16:25 +0000</pubDate>
      <link>https://dev.to/minhaz1217/instantly-preview-rendered-liquid-template-5m7</link>
      <guid>https://dev.to/minhaz1217/instantly-preview-rendered-liquid-template-5m7</guid>
      <description>&lt;p&gt;&lt;a href="https://shopify.github.io/liquid/"&gt;Liquid&lt;/a&gt; is a template language created by shopify. In my use case I use it for generate html that is almost similar looking but differs in data. So when iterating over my HTML, I need to preview the changes I made combined with my data.&lt;/p&gt;

&lt;p&gt;I achieve this using 2 VS code extensions.&lt;/p&gt;

&lt;p&gt;One is &lt;a href="https://marketplace.visualstudio.com/items?itemName=kirchner-trevor.shopify-liquid-preview"&gt;Shopify Liquid Preview&lt;/a&gt; this enables us to connect our data with the template file. &lt;br&gt;
Another one is &lt;a href="https://marketplace.visualstudio.com/items?itemName=george-alisson.html-preview-vscode"&gt;HTML Preview&lt;/a&gt; this will help us preview data connected html file inside vs code.&lt;/p&gt;

&lt;p&gt;Install these 2 extensions.&lt;/p&gt;

&lt;p&gt;So at first create a html file. Mine is named &lt;code&gt;index.html&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;

&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Preview Liquid Template Instantly in vscode&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;div style="width:100%; text-align: center;"&amp;gt;
        &amp;lt;h1&amp;gt;Greetings from {{name}}&amp;lt;/h1&amp;gt;
        &amp;lt;h2&amp;gt;{{post.title}}&amp;lt;/h2&amp;gt;
        &amp;lt;h3&amp;gt;{{post.description}}&amp;lt;/h3&amp;gt;
        {%- if conditional.enabled -%}
        &amp;lt;p&amp;gt;This section is only visible when conditional is enabled&amp;lt;/p&amp;gt;
        {%- endif -%}
    &amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next create a json file that contains your data that will be connected with the HTML file. Mine is named &lt;code&gt;data.json&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "Minhazul Hayat Khan",
  "post": {
    "title": "Preview Liquid Template instantly in vscode",
    "description": "This uses 2 vscode extensions to directly preview the liquid template with data connected"
  },
  "conditional": {
    "enabled": true
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now go to your HTML file and press "CTRL + SHIFT + P" and select the "Shopify Liquid: Open Preview to the side" option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fasri5xom7nwa0fjmh266.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fasri5xom7nwa0fjmh266.png" alt="select open preview to the side" width="800" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After selecting it, select the json file you'd like to connect with the html&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6kk3ru5lsvyo30dk3ti1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6kk3ru5lsvyo30dk3ti1.png" alt="connect data.json" width="760" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If everything is done properly it will generate a Preview with the connected data to the side.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg0a4cxnixrpi9vunerkr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg0a4cxnixrpi9vunerkr.png" alt="data connected html sample" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now click on the Preview html file and press CTRL + SHIFT + p again and select the HTML: Open Preview option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuo0rmel1nbz02fmz9enc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuo0rmel1nbz02fmz9enc.png" alt="select the generated html file and select open preview" width="762" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It will show you the HTML's preview.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuw5iyxx6ik929co44jc1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuw5iyxx6ik929co44jc1.png" alt="Rendered html page" width="800" height="299"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I had to struggle with checking and verifying the template changes for a very long time. I hope this helps someone. All the codes shown here can be found in my repo &lt;a href="https://github.com/minhaz1217/devops-notes/tree/master/70.%20instantly%20preview%20rendered%20liquid%20template"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/minhaz1217/devops-notes/tree/master/70.%20instantly%20preview%20rendered%20liquid%20template"&gt;https://github.com/minhaz1217/devops-notes/tree/master/70.%20instantly%20preview%20rendered%20liquid%20template&lt;/a&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>vscode</category>
      <category>extensions</category>
      <category>shopify</category>
    </item>
    <item>
      <title>Send fluent bit collected logs to Seq</title>
      <dc:creator>Minhaz</dc:creator>
      <pubDate>Tue, 02 Jan 2024 20:26:23 +0000</pubDate>
      <link>https://dev.to/minhaz1217/send-fluent-bit-collected-logs-to-seq-ahb</link>
      <guid>https://dev.to/minhaz1217/send-fluent-bit-collected-logs-to-seq-ahb</guid>
      <description>&lt;p&gt;Here I will setup fluent-bit and seq both with docker and push logs through fluent bit to to seq. &lt;br&gt;
I will also show how to setup fluent bit and seq with docker.&lt;/p&gt;
&lt;h2&gt;
  
  
  Setup a docker network for the containers
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network create fluent-bit_seq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Setting up Seq
&lt;/h2&gt;

&lt;p&gt;At first setup a hashed password to be used&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PH=$(echo 'seqPass%%' | docker run --rm -i datalust/seq config hash)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure that the password variable is ok&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo $PH
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the container&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run --name seq -d --network fluent-bit_seq \
    -p8080:80 --restart unless-stopped \
    -e ACCEPT_EULA=Y -e SEQ_FIRSTRUN_ADMINPASSWORDHASH="$PH" \
    datalust/seq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now browse to &lt;code&gt;localhost:8080&lt;/code&gt; and login into Seq using username=admin password=seqPass%%&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MYYeHmE6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/byo0hbf5vzvrnxpk0cjc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MYYeHmE6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/byo0hbf5vzvrnxpk0cjc.png" alt="Logging into seq" width="751" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kxMeufla--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hahj9sjoqgk6srmewehl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kxMeufla--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hahj9sjoqgk6srmewehl.png" alt="After logging into seq" width="800" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up Fluent Bit
&lt;/h2&gt;

&lt;p&gt;Designate a folder where you'll store the fluent bit configs. In my case the directory is &lt;code&gt;D:/fluent-bit&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Set the directory where fluent bit's config will come from&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export sharedFolder=/var/fluent-bit_seq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start a temporary container to copy default configs from&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -d --rm --name temp cr.fluentbit.io/fluent/fluent-bit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy the configs to your designated folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker cp temp:/fluent-bit/etc/ $sharedFolder
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Stop the temporary container&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker stop temp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now start fluent bit with the config folder mounted as a volume&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -dti --name fluent-bit --network fluent-bit_seq \
    -v $sharedFolder:/fluent-bit/etc \
      cr.fluentbit.io/fluent/fluent-bit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Etlz8z9r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/61ts1ee3aiksqodxiqp3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Etlz8z9r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/61ts1ee3aiksqodxiqp3.png" alt="See what is in the shared folder directory" width="489" height="125"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By default fluent bit is configured to output to std out. So see docker log to see what fluent bit is logging.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker logs fluent-bit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p4fAr09f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1j3x2uvgbaz0oeo2lpri.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p4fAr09f--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1j3x2uvgbaz0oeo2lpri.png" alt="Fluent bit logs" width="708" height="763"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring Fluent Bit to send logs to Seq
&lt;/h2&gt;

&lt;p&gt;Go to the fluent bit configuration directory and search for this section&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# fluent-bit.conf
[OUTPUT]
    name  stdout
    match *
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace this section with this and save&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# fluent-bit.conf
[OUTPUT]
    Name             http
    Match            *
    Host             seq
    Port             5341
    URI              /api/events/raw?clef
    Format           json_lines
    Json_date_key    @t
    Json_date_format iso8601
    Log_response_payload False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now restart the fluent bit container for the changes to take effect.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker restart fluent-bit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--snDMIeWn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8g027cley8tphlcwxaab.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--snDMIeWn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8g027cley8tphlcwxaab.png" alt="after pasting the config" width="459" height="331"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now browse to &lt;code&gt;localhost:8080&lt;/code&gt; and login into Seq using username=admin password=seqPass%% and see that the logs are being written into Seq&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0VOQhm5h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5x1njei7qqe1q2su7l2j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0VOQhm5h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5x1njei7qqe1q2su7l2j.png" alt="Fluent bit is sending message to seq" width="800" height="595"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Thanks for reading, Happy Tinkering :)
&lt;/h3&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://github.com/minhaz1217/devops-notes/tree/master/66.%20send%20fluent%20bit%20logs%20into%20seq"&gt;Github repo&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>devops</category>
      <category>fluentbit</category>
      <category>seq</category>
      <category>docker</category>
    </item>
    <item>
      <title>Setting up fluent bit using docker</title>
      <dc:creator>Minhaz</dc:creator>
      <pubDate>Sat, 30 Dec 2023 00:30:52 +0000</pubDate>
      <link>https://dev.to/minhaz1217/setting-up-fluent-bit-using-docker-67n</link>
      <guid>https://dev.to/minhaz1217/setting-up-fluent-bit-using-docker-67n</guid>
      <description>&lt;h1&gt;
  
  
  Purpose
&lt;/h1&gt;

&lt;p&gt;This is a step by step guide about how to setup fluent bit with docker.&lt;/p&gt;

&lt;p&gt;The fluent bit official installation guide only had documentation about how to run fluent bit using docker but it didn't mention how to set it up.&lt;/p&gt;

&lt;p&gt;So this is my solution to how to setup fluent bit using docker commands only. No docker compose.&lt;/p&gt;

&lt;h1&gt;
  
  
  Steps
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Designate a folder where you'll store the fluent bit configs. In my case the directory is &lt;code&gt;D:/fluent-bit&lt;/code&gt;
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Start a temporary container to copy default configs from
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -d --rm --name temp cr.fluentbit.io/fluent/fluent-bit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Copy the configs to your designated folder
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker cp temp:/fluent-bit/etc/ D:/fluent-bit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stop the temporary container
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker stop temp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Now start fluent bit with the config folder mounted as a volume
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -dti --name fluent-bit -v D:/fluent-bit:/fluent-bit/etc cr.fluentbit.io/fluent/fluent-bit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  By default fluent bit is configured to output to std out. So see docker log to see what fluent bit is logging.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker logs fluent-bit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll see something like this&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RZKNi1Rx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0fznc84ll4g1mo1jx4o1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RZKNi1Rx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0fznc84ll4g1mo1jx4o1.png" alt="docker logs output" width="697" height="293"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Now to make sure that fluent bit is indeed taking configs from our folder. Go to the designated folder and open the fluent-bit.conf folder
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Look for this string
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tag cpu.local
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Change it to this
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tag CPU_LOCAL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Save the file and restart the container
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker restart fluent-bit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Now look at docker logs
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker logs fluent-bit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that the logs are different.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QTy-P2rB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ffoq2qx8pdyl9w3wx6w3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QTy-P2rB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ffoq2qx8pdyl9w3wx6w3.png" alt="Config change worked" width="704" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://github.com/minhaz1217/devops-notes/tree/master/65.%20setting%20up%20fluent%20bit%20with%20docker"&gt;https://github.com/minhaz1217/devops-notes/tree/master/65.%20setting%20up%20fluent%20bit%20with%20docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.fluentbit.io/manual/installation/docker"&gt;https://docs.fluentbit.io/manual/installation/docker&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>devops</category>
      <category>docker</category>
      <category>fluentbit</category>
      <category>deployment</category>
    </item>
    <item>
      <title>MongoDB giving user permission to view only single collection.</title>
      <dc:creator>Minhaz</dc:creator>
      <pubDate>Sun, 24 Dec 2023 21:33:50 +0000</pubDate>
      <link>https://dev.to/minhaz1217/mongodb-giving-user-permission-to-view-only-single-collection-20jk</link>
      <guid>https://dev.to/minhaz1217/mongodb-giving-user-permission-to-view-only-single-collection-20jk</guid>
      <description>&lt;h1&gt;
  
  
  Purpose
&lt;/h1&gt;

&lt;p&gt;Here I will install mongo and set it up in a way where an user can only read and write a single collection or multiple collection but not all.&lt;/p&gt;

&lt;p&gt;As a result it will increase security of the db.&lt;/p&gt;

&lt;h1&gt;
  
  
  Steps
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Install mongodb
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -dit --name mongo -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=mongoAdmin33 mongo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Go into the docker container's mongosh
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec -it mongo bash -c "mongosh mongodb://admin:mongoAdmin33@localhost:27017/?authSource=admin"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Use this command and see that all the dbs are visible
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;show dbs;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It should show 3 collections like this -&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OrcQoLr7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pmwzk3cs9k37svl23c1r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OrcQoLr7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pmwzk3cs9k37svl23c1r.png" alt="Image description" width="192" height="83"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Switch to a db using
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use appleCollection;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gGOMgHA1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qsd1uz7o4i82lqxb3m48.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gGOMgHA1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qsd1uz7o4i82lqxb3m48.png" alt="Image description" width="313" height="60"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Insert some data
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.apples.insertMany([
    {
        title: "Green Apple"
    },
    {
        title: "Red Apple"
    },
    {
        title: "Black Apple"
    }
])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J0Jjtq_U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/frydgnylyp73ugbpclbo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J0Jjtq_U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/frydgnylyp73ugbpclbo.png" alt="after inserting data" width="462" height="157"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Create an user and give him read write access for only this collection
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.createUser(
   {
     user: "apple_admin",
     pwd: "apple_admin_pass",
     roles: [ "readWrite", "dbAdmin" ]
   }
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It should say&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P2viD2w2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4odfzmirsz9ynfdtlkwg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P2viD2w2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4odfzmirsz9ynfdtlkwg.png" alt="after creating user" width="409" height="179"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Exit from the current mongosh using
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Login into mongosh using the new apple admin account
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec -it mongo bash -c "mongosh mongodb://apple_admin:apple_admin_pass@localhost:27017/?authSource=appleCollection"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Please notice that we are using &lt;code&gt;appleCollection&lt;/code&gt; as the auth source.&lt;/p&gt;

&lt;h3&gt;
  
  
  Now use the command to see dbs;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;show dbs;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only one db should be visible.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N0UIx0KU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nqn5oenewjzs0hugf1rk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N0UIx0KU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nqn5oenewjzs0hugf1rk.png" alt="Image description" width="234" height="76"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Select data from this db.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.apples.find({});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DBt6vs46--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y1bt83owwrui68n1bzuv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DBt6vs46--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y1bt83owwrui68n1bzuv.png" alt="find data" width="673" height="139"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Switch to a different database
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use randomDatabase;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Query this database and it should show error.
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;show collections
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nz5kIRvB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4rg5rhhb1azjlf10w48a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nz5kIRvB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4rg5rhhb1azjlf10w48a.png" alt="user don't have permission for this db" width="708" height="127"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Reference
&lt;/h1&gt;

&lt;p&gt;This was one of my projects that I tried out first here. Here you can also find how to give a user multiple database’s permission.&lt;br&gt;
devops-notes/61. setup mongodb and give specific user permission to specific collection. I will update the github if I find something.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/minhaz1217/devops-notes/tree/master/61.%20setup%20mongodb%20and%20give%20specific%20user%20permission%20to%20specific%20collection"&gt;[Github]Giving user permission to specific database&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy and let me know if any problem occurs.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>security</category>
      <category>mongodb</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
