Elasticsearch, a widely used open-source search and analytics engine, often requires the creation of service tokens for authentication purposes. These tokens are typically generated via the command-line interface (CLI) without any issues. However, a recurring problem has been identified when these tokens are used with curl or other types of authentication methods, such as Kibana login.

The error message received is as follows:

received token fails with error
cannot authenticate with auth token to Elasticsearch, error: failed to authenticate service account [elastic/kibana] with token name [<token name>]
Continue reading

Loading

In some times you want to receive notifications from grafana only in working hours. You may configure quiet hours, but in this case grafana show status as unhealthy, just not notifying you.

It’s possible to set hours, when alerts actually present and should be sent.

Just add new prometheus condition with code (time in UTC):

((hour() >= 9) * (hour() <= 18)) OR on() vector(0)

This expression returns 81 at 9:00-9:59, 100 at 10:00-10:59 etc between 9:00 and 18:00 (6 p.m.).

And add condition for this expression >0

First condition – original value expression, second – time interval.

Loading

How to downgrade MS SQL database we can find from web-search. Its discribe simple method – use “Tasks – Generate Scripts…” with data and Win!

standard downgrade method

But! If you have huge database’s size, you cannot use that method. For example: My 10 Gb database, have exported size – 50 Gb. No one text editor can handle this size of plane text file, including command-line import (because its import data from text file line by line and some data cannot be inserted in buffer).

Here is article to help you downgrade huge database in “simple” way.

Continue reading

Loading

To change Remote Desktop certificate in Windows Server 2012R2 you need to do two steps:

Step 1. Get thumbprint of certificate (the name of certificate must be equal of server connection name). It possible from mmc.exe console (add certificates snap-in from computer account and view certificate in personal folder). Copy thumbprint without spaces and special symbol in start of line.

Step 2. Assign certificate from powershell:

$path = (Get-WmiObject -class “Win32_TSGeneralSetting” -Namespace rootcimv2terminalservices -Filter “TerminalName=’RDP-tcp'”).__path
Set-WmiInstance -Path $path -argument @{SSLCertificateSHA1Hash=”THUMBPRINT”} ## in THUMBPRINT pole add value from step 1.

 

Loading

You can compress files and folders from PowerShell without installing third-party application (required .NET Framework 4.5):

[System.IO.Compression.ZipFile]::CreateFromDirectory(“$Source”, “$Archive”)

Here the function listing to use compression easy:

function Add-Zip ($Source, $Archive){
<#
.SYNOPSIS
Compression function

.DESCRIPTION
Native compression with latest .NET 4.5 framework

.PARAMETER Source
Source file or directory for compression

.PARAMETER Archive
Archive file name [with path]

.EXAMPLE
————————– EXAMPLE  —————————
Add-Zip -Source C:Temp -Archive C:Temp.zip

Compress C:temp folder to C:temp.zip archive

.LINK

http://makovetsky.me
#>
If (-Not $Source -or -Not $Archive) {
Write-Host ‘One parameter is missing’
} else {
Add-Type -Assembly “System.IO.Compression.FileSystem” ;
[System.IO.Compression.ZipFile]::CreateFromDirectory(“$Source”, “$Archive”) ;
}}

Loading

You can generate ssh private and public keys to use in ssh connection with puttygen (can be downloaded from link).

Step 1. Open puttygen, choose ‘ssh-2 rsa’ or ‘ssh2 dsa’ and push ‘Generete’ button (move mouse in ‘key’ area).

Step 2. Push ‘save private key’ to save keyfile (you can set password to protect private key).

Step 3. Save text from ‘public key for pasting into OpenSSH authorized_keys file’:

Step 4. Login to remote Linux server (presumably OpenSSH server already installed). Note: lately with this username you should connect with SSH.

Step 5. Create .ssh folder (mkdir ~/.ssh) and change permissions (chmod 700 ~/.ssh).

Step 6. Create file authorized_keys2 in .ssh folder and paste information from ‘Step 3’ into it (your_favorite_editor ~/.ssh/authorized_keys2).

Step 7. Configuring PuTTY:

  • Enter hosthame of remote server in ‘Session’ category.
  • In ‘Data – Connection – Auto-login username’ enter username that used in Sstep 4’.
  • In ‘Connection – SSH – Auth – Private key file for authentication’ put fullpath to file saved in ‘Step 2’.
  • You can save this settings in ‘Session’ category and push ‘Open’ (Note: if you set private key password at this time you should enter it, else putty connect to remote server with private/public key pairs).

Author: Andrey Makovetsky

Loading