Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alert can't be sent to alertmanager #2160

Closed
zybjcdl opened this Issue Nov 4, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@zybjcdl
Copy link

zybjcdl commented Nov 4, 2016

I have setup prometheus and alertmanager in k8s environment.
I can see alert show up in prometheus alert page, but in alertmanager page, I can't see any alert show up. I am using image: quay.io/prometheus/alertmanager:latest

The prometheus page I visit is
https://9.30.99.224/api/v1/proxy/namespaces/monitoring/services/prometheus/alerts
The alertmanager page is:
https://9.30.99.224/api/v1/proxy/namespaces/monitoring/services/alertmanager/#/alerts

Here is the prometheus command line flag:
alertmanager.url=http://localhost:8080/api/v1/proxy/namespaces/monitoring/services/alertmanager/

Here is alertmanager.yml file:

apiVersion: v1
kind: Service
metadata:
  annotations:
    prometheus.io/scrape: 'true'
  labels:
    name: alertmanager
  name: alertmanager
  namespace: monitoring
spec:
  selector:
    app: alertmanager
  ports:
  - port: 9093 # the port that this service should serve on
    targetPort: 9093  # port on container
----
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: alertmanager
  namespace: monitoring
spec:
  replicas: 1
  selector:
    matchLabels:
      app: alertmanager
  template:
    metadata:
      name: alertmanager
      labels:
        app: alertmanager
    spec:
      containers:
      - name: alertmanager
        image: quay.io/prometheus/alertmanager:latest
        args:
          - '-config.file=/etc/alertmanager/config.yml'
          - '-storage.path=/alertmanager'
        ports:
        - name: alertmanager
          containerPort: 9093
        volumeMounts:
        - name: config-volume
          mountPath: /etc/alertmanager
        - name: alertmanager
          #mountPath: /prometheus
          mountPath: /alertmanager
      volumes:
      - name: config-volume
        configMap:
          name: alertmanager
      - emptyDir: {}
        name: alertmanager
----
apiVersion: v1
kind: ConfigMap
metadata:
  name: alertmanager
  namespace: monitoring
data:
  config.yml: |
    global:
      resolve_timeout: 5m
      # The smarthost and SMTP sender used for mail notifications.
      smtp_smarthost: 'smtp.gmail.com:587'
      smtp_from: 'zybjcdl@gmail.com'
      smtp_auth_username: '*****'
      smtp_auth_password: '****'
 route:
  receiver: default

 receivers:
   - name: default
     email_configs:
     - to: 'zybjcdl@gmail.com'
@brancz

This comment has been minimized.

Copy link
Member

brancz commented Nov 4, 2016

If Prometheus and Alertmanager are both in k8s and you have a working dns addon, then you can just use http://alertmanager.monitoring.svc:9093. The generalized pattern of the dns record created for a service is <service-name>.<namespace-name>.svc.

Be aware that this is only a sane setup as long as you are not running the Alertmanager in high availability mode. As soon as you run in HA mode Prometheus needs to be configured to fire all alerts against all Alertmanagers as opposed to loadbalancing the fired alerts to an Alertmanager chosen by the load balancer.

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 24, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.