background preloader

Pratique

Facebook Twitter

Dashboard Grafana dockerizé. A l’instar de SLF4J pour les logs, Micrometer est la façade d’export de métriques utilisée par Spring Boot et ses Actuators. Micrometer supporte une douzaine de systèmes de monitoring : Datalog, Netflix Atlas, New Relic, JMX, CloudWatch, InfluxDB ou bien encore Prometheus. Récemment, j’ai poursuivi le travail initié par Kevin Crawley pour intégrer Prometheus et Grafana dans la version microservices de Spring Petclinic. Proposée par Maciej Szarliński, l’idée consistait à remplacer les compteurs Micrometer de typeregistry.counter(« create.visit »).increment() par l’annotation @Timed. J’ai profité de ce changement pour améliorer le packaging Docker de Grafana et en simplifier l’accès. Docker compose Le docker-compose.yml de Spring Petclinic Microservices est relativement simple : il pointe sur 2 Dockerfile Grafana et Promotheus personnalisés. grafana-server: build: .

Dockerfile Prometheus FROM prom/prometheus:v2.4.2 ADD prometheus.yml /etc/prometheus/ Dockerfile Grafana Conclusion Ressources : Proxmox 5 : cluster 2 nœuds avec un stockage répliqué. ES6 for beginners - Part 1 (Let, Const) 2n it sp. z o.o. Tutoriel pour programmer avec Node.js et MongoDB. Dans ce tutoriel, nous allons modifier une application, précédemment connectée à SQLite 3, pour qu'elle utilise MongoDB, l'une des bases de données NoSQL les plus populaires pour les applications Node.js. NoSQL fait référence à un type de base de données constituant une alternative à la base de données relationnelle. Les trois types de bases de données NoSQL sont les suivants : MongoDB est une base de données orientée document qui utilise un format JSON binaire (appelé BSON) pour le stockage des données. Comme d'autres bases de données NoSQL, MongoDB a été popularisé par la demande de données volumineuses.

Dans ce tutoriel, vous allez configurer MongoDB en tant que base de données pour l’application « Liste de shopping », puis effectuer une série d’opérations de base de données courantes à l’aide de MongoDB. Vous verrez comment ces opérations se comparent entre SQLite 3 et MongoDB. Ce tutoriel fait partie d’un parcours de formation Node.js , proposé par IBM.

MacOS Windows Linux V-A. V-B. Grafana : Superviser tous vos serveurs et périphériques avec classe. Aujourd’hui on va parler un peu supervision. C’est génial d’avoir des dizaines de serveurs, de faire du clustering, d’avoir des périphériques tels que des routeurs, switchs, onduleurs ou autres joyeusetés. Mais s’il n’y a aucune supervision sur tous ces appareils, cela peut vite devenir catastrophique sans que l’on en s’aperçoive. Alors des systèmes de supervision, il en existe des dizaines, payant ou gratuit, bon ou moins bon. On va ici s’intéresser à Grafana qui est celui que j’ai récemment mis en place. Avec Grafana, vous allez pouvoir monter de magnifiques Dashboard qui plairons à coup sûr à votre direction. Et ce qui plaira encore plus à votre direction, c’est que Grafana est Open-Source. Vous en doutez ? Du Dashboard en veux-tu en voilà !

Dashboard Lab Dans l’exemple ci-dessous un Dashboard qui récupère les infos d’un LAB ESXi, avec les remontées d’info des NAS Synology et de l’onduleur. Dashboard Synology Récupération des infos de serveur NAS Synology via SNMP. Dashboard Hyper-V InfluxDB. Tu maîtrises les fonctions, mais qu'en est-il des "functors" ? Build a Cron-Job in Nodejs. React, Nginx, & Docker – reino. // Within 10 mins you'll have a Dockerized React App Firstly, we’ll build a simple React app;Secondly, build a production ready Docker image of a React app with Node.js and Nginx;Then test and run the Docker image that will create our container. // TL;DR - Don't Have 10 mins!

GitHub Repo: git clone cd react-docker docker build -t react-docker . docker run -p 80:80 react-docker Read on for more details... // No Worries Newbies! React is a JavaScript library for building user interfaces. Need to know more? Docker is a technology designed to simplify the development, deployment and run applications through the use of containers. Need to know more? Node.Js is a run-time environment that executes JavaScript code outside of a browser. Need to know more? Nginx is a web server which can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache.

Need to know more? // Prerequisite // Step One - React. Paramétrer Google Analytics pour plusieurs sous domaines. Ma problématique du jour est liée à la récolte de données, l'utilisation de Google Analytics sur mon site et tout ces trucs. Jusqu'à maintenant, seul le blog était suivi via Google Analytics. C'est la partie la plus importante du site : le contenu est plus conséquent, il change (grossi) régulièrement, vos goûts ne se manifestent pas de la même façon d'un article à l'autre ce qui me permet d'apprendre à vous connaitre.

Ceux qui me suivent sur les réseaux sociaux ne sont pas sans savoir que j'ai entrepris la refonte total de mon site nathanaelcherrier.com qui comprend aussi: Cette architecture va bientôt changer à cause de la refonte (je vous en parlerais plus dans un autre billet) mais c'est pour que vous vous fassiez une idée de l'exemple.

Ce dont j'ai envie avec cette réécriture c'est de savoir si elle vous plait autant que j'ai aimé la réaliser. Est-ce que j'ai perdu mon temps ou pas ? Pour avoir ces informations, je me tourne donc vers Google Analytics. Un seul site ou plusieurs sites ? Gets Real-time Push Capabilities! Being able to broadcast data in real-time from servers to clients is a requirement for many modern web and mobile applications. Because the most popular PHP SAPIs aren't able to maintain persistent connections, Symfony wasn't providing any built-in method to push data to clients until now. It was mandatory to rely on external service providers or on other programming languages to implement such feature.

This time is over! Say hello to the Mercure component and to the MercureBundle! As their names indicate, they implement Mercure, an open protocol designed from the ground up to publish updates from server to clients. These two newcomers in the Symfony family are specifically designed for use cases requiring real-time capabilities such as: Creating an UI reacting in live to changes made by other users (e.g. a user changes the data currently browsed by several other users, all UIs are instantly updated)notifying the user when an asynchronous job has been completedcreating chat applications Tip. Security Headers to use on your webserver. Introduction Dozens of websites are hacked because of misconfiguration or a lack of protection. You can indeed see on the OWASP Top 10, which are the Top 10 identified flaws on web servers and services from the OWASP (Open Web Application Security Project), that the Security Misconfiguration is the most identified cause of vulnerabilities on web services.

This is commonly a result of insecure default configurations, incomplete or ad-hoc configurations, open cloud storage, misconfigured HTTP headers, and verbose error messages containing sensitive information. Not only must all operating systems, frameworks, libraries, and applications be securely configured, but they must be patched/upgraded in a timely fashion. Let's deep dive on the weaknesses and impacts of it. In this post, we are going to go through the headers and configuration you should use on your project in order to secure your server. Before you start : Let us review the HTTP headers list that we are going to cover : 1. 2. 3. 4. 10 bonnes pratiques PHP pour améliorer son code. Depuis maintenant plus d’un an, j’enseigne le PHP à des élèves d’une école digitale, aussi bien à des débutants qu’à des élèves confirmés. Je démarre tous mes cours par le partage de ces notions et la présentation d’un ensemble de bonnes pratiques.

Ce sont ces mêmes pratiques que nous avons mis en place en interne également chez Web and Cow. Chaque développeur qui rejoint l’équipe est invité à les consulter et à les respecter. C’est primordial pour que le code de chacun puisse être compréhensible et repris par tous. Attention, d’une organisation à une autre, d’une entreprise à une autre, ces bonnes pratiques et conventions peuvent changer. Ecriture Les noms des variables, des fonctions, des méthodes et des attributs sont écrits en camelCase. $maVariableNumerique = 3; function sommeDesEntiers($maximum) {...} Les noms des clés dans un tableau sont écrites en snake_case. $user = [ 'username' => 'monadresse@mail.com', 'first_name' => 'John', 'last_name' => 'Doe', 'active' => 1 ]; Respect du typage.

Envoyer des logs applicatifs Symfony vers Slack avec Monolog. Publié le 14/03/2019 • Mis à jour le 20/03/2019 Dans cet article nous allons voir comment envoyer des logs d'une application Symfony vers Slack. Une utilisation typique est de transmettre les erreurs critiques en temps réel pour pouvoir réagir rapidement et corriger les problèmes. Nous pouvons bien sûr aussi envoyer d'autres types de notifications. C'est parti mon kiki ! 😎 Configuration Le code que vous voyez étant directement celui utilisé par ce projet Symfony, vous êtes sûr qu'il est à jour. Symfony 4.2.4 PHP 7.2 Configuration de l'API Slack Quand j'ai commencé à écrire ce tutoriel, j'utilisais encore une vieille clé API. PS : Attention, si c'est une chaîne privée, il faudra aussi donner le doit chat:write:user. Pour que nous puissions consommer cette API nous avons besoin d'un jeton OAuth.

SLACK_TOKEN=xoxp-1111111-22222222-33333333-aaaaaaaaaaaaaaaaaaaaaa Dans le fichier .env.dist ajoutez aussi cette clé. SLACK_TOKEN= Utilisation. Créer un cluster 2 nodes Proxmox. Bonjour à tous, Aujourd’hui nous allons aborder une fonctionnalité intéressante des distributions Proxmox qui permet de faire du “clustering” avec deux ou plusieures machines physiques.

Pour aujourd’hui nous verrons une notion simple de cluster sans haute disponibilité basé sur 2 machines physiques seulement. Cette configuration est intéressante lorsqu’il n’y a pas un réel besoin de haute disponibilité, mais un besoin de répartition de charge et/ou de reprise de service anticipé en cas d’incident. Le “cluster” Proxmox permet notamment de faire de la migration de container d’une machine à une autre “à chaud”, de gérer l’ensemble de ces containers à partir de l’un ou l’autre des hyperviseurs … bref rien d’indispensable en soit mais pas mal de petites choses foutrement utiles. Rien de surprenant ici, la première étape consistera à installer une distribution Proxmox sur vos deux machines. Préparer le réseau 127.0.0.1 localhost.localdomain localhost 87.37.23.91 tartanpion.elao.local tartanpion.

End-to-end application development Part 1— Starting strong. Why this post? I am starting in a new team today. Most of the team is new to DevOps and the technologies that we are going to use in the project. This post is an effort to capture the discussions and have a formal way of starting for newcomers. What will we eventually build? I think it is easier to think about starting with a project/concept with an aim to build something in mind. I wish i could talk through the project we are working on without legal issues, but for now, we will do this. Our end goal is to create a cross platform mobile application that talks to an authenticated api. How will we do that? The general rule in the programming world is to start with saying “hello”, and that is good, because it helps you get the most basic application running. The Mantra for new projects. My mantra for new project setup is this Okay, that was not really helpful. That still may not make much sense. 1. And on the seventh day, Linus said, let there be Git To copy over from this Stack OverFlow answer.

Let’s Dockerize a Nodejs Express API. NodeJS Hello World! To start with, let’s create a minimal nodejs api consisiting a simple GET route. For this example i’ll be using expressjs which is a popular framework for nodejs. Initialize a new npm project npm init 2. Touch .gitignoretouch .dockerignoretouch server.js 3. 4. Npm install --save express core body-parser @rama41222/node-logger 6. Npm install --save-dev nodemon 5. 6. 7. Npm run dev 8. 2019–03–27 00:25:56 info: sample-express-app running on 0.0.0.0:3000 We are almost done with nodejs coding. Docker File First create a Dockerfile and a docker-compose.yml to run the nodejs api using docker. touch Dockerfiletouch docker-compose.yml 2. Let’s quickly walk through the Dockerfile So in the docker file, we are using the alpine image since it’s very simple, light weight and more secure. FROM node:11-alpine RUN is an image build step, the state of the container after a RUN command will be committed to the docker image.

RUN mkdir -p /usr/src/app WORKDIR /usr/src/app Copy all files to the image. 4 Ways to Test Your APIs End to End – Dotan Nahum. Supertest Starting with Supertest — one of the most popular integration testing library for Javascript and Node.js. You use it on top of your existing testing framework, and it offers a nice fluent-interface for defining API tests (black-box or white-box). ❎ Self-contained — No. Has to have a testing framework to drive it. ✅ Integration tests — Yes. ✳️ Test definition as configuration — No. But if you really squint you can look at its fluent-interface as a DSL for a configuration language. ✅ Variable passing — Yes. . ✅ Set up and tear down — Yes. . ❎ Contract validation — No. ✳️ Content validation — Yes. Notable mention: hippie which has a similar approach. Dredd Dredd is a tool backed by Apiary (now part of Oracle).

It can take API Blueprint or Swagger (now OpenAPI) descriptions for your API and validate (aka test) your live services or service under test. ✅ Self-contained — Yes. ✅ Integration tests — Yes. ✅ Test definition as configuration — Yes. . ✅ Set up and tear down — Yes. Newman (and Postman) How to Protect Your Server From Hackers. This post was originally posted in my personal blog. It is not a hard deal to make your server secure, but when a lot of routines comes, It is possible to forget to do this. In my case, ssh server was hacked in two weeks after I bought it. One morning my mail had a couple of the abuses from third-side people said "something" on my server tried to hack their servers.

So, I should solve the problem quickly. How to find the vulnerability In my case it was simple. Cat /var/log/auth.log | grep Accepted and it returns me a list of successful authorization to my server. How to protect server Briefly about what I needed to do immediately after buying the server. Install ufw - plain firewall;close all server's ports besides SSH, HTTP(s) ports;Install and config fail2ban utility. What to do? If you were hacked, your server is infected, and you need to know how to research and clean it. Ssh-keygen It creates the pairs of keys in the ~/.ssh directory. Ssh-copy-id you_user@your_server_id and enable the ufw: Symfony4 Kubernetes Local Development Environment #1 Simple Construct. JavaScript Resources - Podcasts, Books, Videos and Tutorials.

JavaScript One-Liners That Make Me Excited. Dust off your ternary expressions, we're going in. One-liners are tricky to maintain (and sometimes even hard to understand) but that doesn't stop them from being cool as hell. There's a certain satisfaction that comes after writing a terse solution. This is a collection of some of my recent favorites. They will all run in your dev console so pop it open and try them out. I hope you'll share some of your own favorites in the comments! Calendar Hacking Ali Spittel tweeted this out recently. // Create an array of the past seven days, inclusive[...Array(7).keys()].map(days => new Date(Date.now() - 86400000 * days)); Random ID generation This is my go-to function for creating UUIDs when prototyping. // Generate a random alphanumerical string of length 11Math.random().toString(36).substring(2); Quines I've picked some winners for you.

Scrape query parameters Talk about non-maintainable code. // Get the current page's query parameters as an objectdocument.location.search.replace(/(^\?) Working clock. Tutorial.