5 Temmuz 2023 Çarşamba

AWS Systems Manager

Giriş
Açıklaması şöyle
With Systems Manager, users exchange their AWS credentials for temporary shell access ....
EC2 instance'ları için AWS Resource Groups içinde tag yaratarak AWS Systems Manager ile hepsine shell komutunu çalıştıran bir örnek burada

AWS Systems Manager Parameter Store
Parameter Store ayarlarına sol taraftaki menüden erişilir. Açıklaması şöyle
AWS Systems Manager Parameter Store provides secure storage and management of secrets. It allows storing of data such as passwords, database strings, Amazon Elastic Compute Cloud (Amazon EC2) instance IDs and Amazon Machine Image (AMI) IDs, and license codes as parameter values. It can store values as plain text or encrypted data.
AWS Systems Manager Parameter Store vs AWS Secrets Manager
AWS Secrets Manager daha fazla özellik sağlıyor. Örneğin secret rotation gibi.

4 Temmuz 2023 Salı

UML Package Diagram

Giriş
Açıklaması şöyle
The UML package diagram describes the structures of the designed system at the level of packages or the dependencies between the packages that make up a model.
Paketler Arası Bağımlılıklar
Bağımlılıkları gösteren bir örnek burada. Bağımlılıklar kesikli açık ok (dashed open arrow) ile gösterilir. Bağımlılıklar için stereotype etiketler kullanılabilir. Bunların bazıları şöyle
1. <<import>>
Açıklaması şöyle
One package imports the functionality of another package. Only public elements in the package will be imported.
2. <<access>>
Açıklaması şöyle
One package requires assistance from functions of another package. 
3. <<merge>>
Açıklaması şöyle. Bence extends diye adlandırılsaydı daha iyi olurdu
It is the directed relationship between 2 packages that indicates that the content of one package is extended by the contents of another package. 

AWS Transcribe

Giriş
Açıklaması şöyle
Amazon Transcribe is a service that utilizes Machine Learning models to convert speech to text automatically. It offers various features that can enhance the accuracy of the transcribed text, such as language customization, content filtering, multi-channel audio analysis, and individual speaker speech partitioning. Amazon Transcribe can be used as a standalone transcription service or to add speech-to-text capabilities to any application. You can transcribe media in real-time (streaming) or you can transcribe media files located in an Amazon S3 bucket (batch).

3 Temmuz 2023 Pazartesi

aws ecr seçeneği - Container Registry

create-repository seçeneği
--repository-name ile ismi belirtilen yeni bir repository yaratılır

Örnek
Açıklaması şöyle
The container should be published to a registry. For this end, we’ll use Amazon ECR, a managed container registry to store, share, and deploy containers in the AWS Cloud.
...
Now, for each microservice container image, we need to create an ECR repository. Please note the repository name should exactly match the container image repository name.

Here’s the command to create a repository in ECR for the Order container image:
Şöyle yaparız
> aws ecr create-repository --repository-name microservice-customer
Çıktısı şöyle
{
  "repository": {
  "repositoryArn": "arn:aws:ecr:eu-central-1:877546708265:repository/microservice-customer",
  "registryId": "877546708265",
  "repositoryName": "microservice-customer",
  "repositoryUri": "877546708265.dkr.ecr.eu-central-1.amazonaws.com/microservice-customer",
  "createdAt": "2021-03-04T00:18:33+01:00",
  "imageTagMutability": "MUTABLE",
  "imageScanningConfiguration": {
    "scanOnPush": false
  },
  "encryptionConfiguration": {
    "encryptionType": "AES256"
  }
}
Yerel image yeniden tag'lenir ve push edilir. Şöyle yaparız
> docker tag 652da8e2130b 877546708265.dkr.ecr.eu-central-1.amazonaws.com/microservice-customer:1.0.0

> aws ecr get-login-password \
  --region eu-central-1 | \
  docker login \
    --username AWS \
    --password-stdin \
    877546708265.dkr.ecr.eu-central-1.amazonaws.com

> docker push 877546708265.dkr.ecr.eu-central-1.amazonaws.com/microservice-customer:1.0.0
delete-repository seçeneği
--repository-name ile ismi belirtilen repository silinir

Örnek
Şöyle yaparız
aws ecr delete-repository --repository-name hello-app-runner --force
get-login-password seçeneği
docker veya podman ile login olup image push etmek için şifre gerekir. Şifreyi ortamdan çekmek için bu seçenek kullanılır

Örnek - docker
Login olmak için şöyle yaparız
aws ecr get-login-password --region eu-central-1 | 
docker login 
  --username AWS 
  --password-stdin 378612673110.dkr.ecr.eu-central-1.amazonaws.com/java-demo
Örnek - podman
Şöyle yaparız
# Create an ECR repository
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
export AWS_REGION=us-east-1
aws ecr create-repository --repository-name hello-app-runner

# Authenticate with an external container registry and push the generated image
podman login --username AWS --password $(aws ecr get-login-password \
     --region ${AWS_REGION}) ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com
podman tag hello-app-runner:latest \
  ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/hello-app-runner:latest

H.264 Nedir? - Bir Codec Standardı

Giriş
H.264 bir codec standardı. Açıklaması şöyle. Yani video cihazından görüntüyü yakalar ve dijital hale getirir.
H.264 is one of the most popular codecs for live video streaming, and it can be used to create video files in various resolutions up to 8k.
Bu standardı gerçekleştiren farklı encoder'lar var. Farkı vurgulayan bir açıklama şöyle
Consider the case for H.264. The standard's name is H.264 – that's not the name of the actual encoder. Mainconcept is a very good commercial encoder, whereas x264 is a free and open source one. 
...
The mere fact that you can optimize encoding makes for a competition here. Both encoders will deliver a standardized bitstream that can always be decoded by a H.264-compliant decoder.
Sıkıştırma
Açıklaması şöyle. Sıkıştırma yöntemlerinden bir tanesi interframe compression. İki frame arasındaki fark gönderilir.
How does H.264 encoding work?

H.264 is a video compression standard that is commonly used to encode video files for a variety of purposes, including streaming over the internet. H.264 uses a combination of techniques to reduce the size of video files without significantly impacting the quality of the video. One of the key techniques used by H.264 is known as “interframe compression.” This technique involves analyzing the differences between consecutive frames of the video and only storing the information that has changed from one frame to the next. By storing only the differences between frames, H.264 is able to significantly reduce the amount of data that is required to represent the video. H.264 also uses techniques such as quantization, entropy coding, and motion compensation to further reduce the size of the video data. These techniques involve analyzing the video data and removing redundant or irrelevant information, as well as using advanced mathematical algorithms to represent the data more efficiently.

22 Haziran 2023 Perşembe

Prometheus prometheus.yml Dosyası - Scrape Configurations

Giriş
Burada sorgulanacak sunucuların bilgileri tanımlı. Açıklaması şöyle
The attribute job_name is used to define the name of the target we monitor, here we set it as “prometheus”.

The targets attribute is used to define the address of the target, which will be an array of addresses.

The default configuration of Prometheus is to monitor itself, when you run Prometheus it will listen on port 9090 and provide a path /metrics for us to get its metrics.
static_configs Alanı
Sorgulanacak sunucuların adreslerini belirtir.

Örnek
Şöyle yaparız
global:
  scrape_interval: 15s
scrape_configs:
  - job_name: 'darwin-service-1'
    scrape_interval: 5s
    static_configs:
      - targets: ['darwin-service-1:80']
    relabel_configs:
      - source_labels: [job]
        target_label: job
        replacement: 'darwin-new-service'

  - job_name: 'darwin-service-2'
    scrape_interval: 10s
    static_configs:
      - targets: ['darwin-service-2:80']
Açıklaması şöyle
In this example, two separate static_configs blocks are defined, each with a different job_name. The first block scrapes a single target, darwin-service-1:80, every 5 seconds, while the second block scrapes a single target, darwin-service-2:80, every 10 seconds.
Örnek - Jenkins
Jenkins'e Prometheus eklentisi kurulur. Kurduktan sonra adres şöyledir "<Public-
IP:8080/prometheus>"
Şöyle yaparız
- job_name: "Jenkins Job"
  static_configs:
    - targets: ["<Public IP of Jenkins Node:8080"]
Örnek
Şöyle yaparız. 
global:
scrape_interval: 5s scrape_configs: - job_name: prometheus honor_labels: true static_configs: - targets: [ "localhost:9090" ] - job_name: 'spring_micrometer' metrics_path: '/actuator/prometheus' scrape_interval: 5s static_configs: - targets: ['your_host_ip:8080']
metrics_path Alanı
Örnek
Şöyle yaparız
scrape_configs:
  - job_name: 'Spring Boot Application input'
    metrics_path: '/actuator/prometheus'
    scrape_interval: 2s
    static_configs:
      - targets: ['localhost:8000']
        labels:
          application: "My Spring Boot Application"
Örnek
Şöyle yaparız. Bu bir spring uygulamasını sorgular
scrape_configs:
    - job_name: 'spring-actuator'
      metrics_path: '/actuator/prometheus'
      scrape_interval: 5s
      static_configs:
        - targets: ['127.0.0.1:8080']
Örnek
Şöyle yaparız. Bu bir spring uygulamasını sorgular
global:
  scrape_interval:   15s

  external_labels:
    monitor: 'quiz-server-monitoring'

scrape_configs:
- job_name:       'quiz-server'
  scrape_interval: 10s
  metrics_path: '/actuator/prometheus'
  static_configs:
  - targets: ['app:8080']
    labels:
      application: 'quiz-server'
Örnek
Şöyle yaparız. Bu bir spring uygulamasını sorgular
global:
  scrape_interval: 10s
scrape_configs:
  - job_name: 'spring_micrometer'
    metrics_path: '/actuator/prometheus'
    scrape_interval: 5s
    static_configs:
      - targets: ['192.168.2.8:8080']
relabel_configs Alanı - Relabeling 
Açıklaması şöyle
Relabeling allows you to transform or modify the scraped data labels before storing them in the time-series database. This is useful for modifying labels to match your naming conventions or adding additional metadata to the scraped data.
Örnek
Açıklaması şöyle
For instance, if you want to modify the job label of darwin-service-1 and save the scraped metrics to a new value, say darwin-new-service, you relabel the prometheus.yml configuration file as follows.
Şöyle yaparız
global:
  scrape_interval: 15s
scrape_configs:
  - job_name: 'darwin-service-1'
    scrape_interval: 5s
    static_configs:
      - targets: ['darwin-service-1:80']
    relabel_configs:
      - source_labels: [job]
        target_label: job
        replacement: 'darwin-new-service'

  - job_name: 'darwin-service-2'
    scrape_interval: 10s
    static_configs:
      - targets: ['darwin-service-2:80']
resources Alanı
Açıklaması şöyle
In a default Prometheus configuration, you deploy containers without resource limits, consequently leading to suboptimal performance of the operating cluster. Instead, you can configure resource consumption at the job, instance, or global level by explicitly defining the limit in the prometheus.yml configuration file.   
Şöyle yaparız
global:
  scrape_interval: 15s
scrape_configs:
  - job_name: 'darwin-service-1'
    scrape_interval: 5s
    static_configs:
      - targets: ['darwin-service-1:80']
    relabel_configs:
      - source_labels: [job]
        target_label: job
        replacement: 'darwin-new-service'
    resources:
      requests:
        memory: 2Gi
        cpu: 1
      limits:
        memory: 4Gi
        cpu: 2

  - job_name: 'darwin-service-2'
    scrape_interval: 10s
    static_configs:
      - targets: ['darwin-service-2:80']
    resources:
      requests:
        memory: 1Gi
        cpu: 0.5
      limits:
        memory: 2Gi
        cpu: 1
alerting Alanı
Açıklaması şöyle. Yani alert olursa hangi kanala gönderileceği burada tanımlı
The alerting section contains the configuration of the tool that we will send an alert to if there is a problem with our system
Açıklaması şöyle
Alerting rules are used to define conditions under which alerts are triggered. As an essential part of monitoring and reliability engineering, you can set up notifications via various channels such as email, Slack, or Squadcast to help detect and resolve issues before they become critical.

In this case, the rule_files field points to a directory containing alert rules, which define the conditions under which alerts are triggered. Triggered alerts get sent to the specified Alertmanager targets, which you can further configure to send notifications to various channels, such as email or the Squadcast platform.
Örnek
Şöyle yaparız
global:
  scrape_interval: 15s
  evaluation_interval: 1m

rule_files:
  - /etc/prometheus/rules/*.rules

scrape_configs:
  - job_name: 'darwin-service-1'
    scrape_interval: 5s
    static_configs:
      - targets: ['darwin-service-1:80']
    relabel_configs:
      - source_labels: [job]
        target_label: job
        replacement: 'darwin-new-service'
    resources:
      requests:
        memory: 2Gi
        cpu: 1
      limits:
        memory: 4Gi
        cpu: 2
    alerting:
      alertmanagers:
      - static_configs:
        - targets:
          - alertmanager:9093
  - job_name: 'darwin-service-2'
    scrape_interval: 10s
    static_configs:
      - targets: ['darwin-service-2:80']
    resources:
      requests:
        memory: 1Gi
        cpu: 0.5
      limits:
        memory: 2Gi
        cpu: 1

    alerting:
      alertmanagers:
      - static_configs:
        - targets:
          - alertmanager:9093


19 Haziran 2023 Pazartesi

aws sso seçeneği

login seçeneği
Örnek
Şöyle yaparız. Tarayıcıyı başlatır ve  AWS SSO login sayfasında yönlendirir. Burada kullanıcı adı ve şifreyi gireriz.
$ aws sso login 
Tüm çıktı şöyle
> aws s3 ls --profile poweruser

The SSO session associated with this profile has expired or is otherwise invalid. 
To refresh this SSO session run aws sso login with the corresponding profile.

> aws sso login --profile poweruser
Attempting to automatically open the SSO authorization page in your default browser.
If the browser does not open or you wish to use a different device to authorize this
request, open the following URL:

https://device.sso.us-east-1.amazonaws.com/

Then enter the code:

ABCD-EFGH
Successfully logged into Start URL: https://fooo.awsapps.com/start

> aws s3 ls --profile poweruser
...