E-mail alert notification in Grafana - database

Hello friends I have a problem in configuring the email alert notification in Grafana like always getting like
Failed to send alert notifications
But if I save it's working but while clicking send test that alone does not come properly. Here is my custom.ini config file here below and help me to solve this error friends.
[smtp]
enabled = true
host = smtp.office365.com:587
user = sample12#domain.com
# If the password contains # or ; you have to wrap it with trippel quotes. Ex """#password;"""
password = xxxxxxxxx
;cert_file =
;key_file =
skip_verify = true
from_address = sample12#domain.com
from_name = Grafana
# EHLO identity in SMTP dialog (defaults to instance_name)
;ehlo_identity = dashboard.example.com

Related

Usename Ldapsearch on Active Directory where AD Domain is different from email domain

I am using Ldap in Debian 11 to authenticate users for Postfix against MS Active Directory with domain mandala.com. The request uses the user's email edmond#example.com to search with this script:
<code>
server_host = 192.168.2.3
search_base = dc=example,dc=com
version = 3
bind = yes
start_tls = no
bind_dn = vmail
bind_pw = mypass
scope = sub
query_filter = (&(objectclass=person)(userPrincipalName=%s))
result_attribute= userPrincipalName
result_format = %d/%u/Maildir/
debuglevel = 1
</code>
The problem is that Postfix uses the user's email edmond#example.com while on the Ad the user is edmond#mandala.com, hence the recipient cannot be found.
if I run an ldapsearch on the command line using dc=mandala, dc=com the user is found.
I solved it passing the mail attribute
<code>
query_filter = (&(objectclass=person)(mail=%s))
result_attribute= mail
<code>

Connecting EventHubConsumerClient to Azure IoTHub does not work with managed identity

I am trying to consume IoTHub messages with EventHubConsumerClient in python.
(I also tried the csharp EventProcessorClient, it seems to have the same problem)
I am running the EventHubConsumerClient in a VM.
The setup:
IoT Hub accessible from the internet.
User assigned identity, added to VM.
User assigned identity has role "IoT Hub Data Reader" with scope set to the IoT Hub
BlobCheckpointStore connected to a blob storage, authenticated with the managed identity (I checked, it works)
Region West Europe
Everything works fine if I use the event hub connection string to connect to the IoT Hub.
But when I use managed identity credential, I get the following error:
evtconsumer | INFO:uamqp.c_uamqp:Token put complete with result: 3, status: 401, description: b'InvalidIssuer: Token issuer is invalid. TrackingId:0315ff67-60c5-4bb2-ba6d-160f45eb91eb, SystemTracker:NoSystemTracker, Timestamp:2021-09-15T10:30:05', connection: b'a44766f1-5d50-4d61-958e-52f7529315a4'
evtconsumer | INFO:uamqp.authentication.cbs_auth:Authentication status: 401, description: b'InvalidIssuer: Token issuer is invalid. TrackingId:0315ff67-60c5-4bb2-ba6d-160f45eb91eb, SystemTracker:NoSystemTracker, Timestamp:2021-09-15T10:30:05'
evtconsumer | INFO:uamqp.authentication.cbs_auth:Authentication Put-Token failed. Retrying.
My code:
import logging
import os
import sys
from azure.identity import ManagedIdentityCredential
from azure.eventhub import EventHubConsumerClient
from azure.eventhub.extensions.checkpointstoreblob import BlobCheckpointStore
logging.basicConfig(stream = sys.stdout, level = logging.INFO)
_logger = logging.getLogger()
azure_client_id = os.getenv("AZURE_CLIENT_ID")
evthubnamespace = os.getenv("IOTHUB_EVTHUB_FULLY_QUALIFIED_NAMESPACE")
evthubname = os.getenv("IOTHUB_EVTHUB_NAME")
evthubconnectionstring = os.getenv("IOTHUB_EVTHUB_CONNECTION_STRING")
blob_account_url = os.getenv("BLOB_ACCOUNT_URL")
blob_container_name = os.getenv("BLOB_CONTAINER_NAME")
# for toggling between authentication methods:
use_connection_string = os.getenv("USE_CONNECTION_STRING") == "true"
credential = ManagedIdentityCredential(client_id=azure_client_id)
def on_event(partition_context, event):
# Print the event data.
_logger.info("Received the event: \"{}\" from the partition with ID: \"{}\"".format(event.body_as_str(encoding='UTF-8'), partition_context.partition_id))
# Update the checkpoint so that the program doesn't read the events
# that it has already read when you run it next time.
partition_context.update_checkpoint(event)
def main():
# Create an Azure blob checkpoint store to store the checkpoints.
checkpoint_store = BlobCheckpointStore(
credential=credential,
blob_account_url=blob_account_url,
container_name=blob_container_name)
if use_connection_string:
# this works fine
_logger.info("Using connection string")
client = EventHubConsumerClient.from_connection_string(
evthubconnectionstring,
consumer_group="$Default",
checkpoint_store=checkpoint_store)
else:
# This causes errors
_logger.info(f"Using managed identity. fully_qualified_namespace: {evthubnamespace} eventhub_name: {evthubname}")
client = EventHubConsumerClient(
fully_qualified_namespace=evthubnamespace,
eventhub_name=evthubname,
consumer_group="$Default",
checkpoint_store=checkpoint_store,
credential=credential)
with client:
# Call the receive method. Read from the beginning of the partition (starting_position: "-1")
client.receive(on_event=on_event)
if __name__ == '__main__':
main()
I am all out of ideas with this one. It seems the AMQP event hub interface of the IoT hub does not accept the tokens generated from the managed identity credential?

Message insert - adding external label

I'm using gmail API to insert an email to the inbox. When the From domain is outside the organization, I expect the external label to be added but it's not.
I'm using python and everything else is working, I am using a service account and able to impersonate on behalf the user's email and I'm using labelIds of ['INBOX', 'UNREAD'] and I need the newly external label as well but couldn't figure a way to add it through the API.
This feature is turned ON for the workspace.
Update - adding my code:
from googleapiclient import discovery, errors
from google.oauth2 import service_account
from email.mime.text import MIMEText
import base64
SERVICE_ACCOUNT_FILE = 'insert-messages-91e77b62878f.json'
SCOPES = ['https://www.googleapis.com/auth/gmail.insert']
def validationService():
# Set the credentials
credentials = service_account.Credentials.\
from_service_account_file(SERVICE_ACCOUNT_FILE, scopes= SCOPES)
# Delegate the credentials to the user you want to impersonate
delegated_credentials = credentials.with_subject('<some_user>')
service = discovery.build('gmail', 'v1', credentials=delegated_credentials)
return service
def SendMessage(service, message):
message = service.users().messages().insert(userId='me', body=message).execute() # me will use <some_user> from above
return message
def CreateMessage(sender, to, subject, message_text):
message = MIMEText(message_text)
message['To'] = to
message['From'] = sender
message['Subject'] = subject
return {'raw': base64.urlsafe_b64encode(message.as_string().encode()).decode(), 'labelIds': ['INBOX', 'UNREAD']}
def main():
try:
service = validationService()
email = CreateMessage('some#external.com', "<some_user>", "Test", "This is a test")
email_sent = SendMessage(service, email)
print('Message Id:', email_sent['id'])
except errors.HttpError as err:
print('\n---------------You have the following error-------------')
print(err)
print('---------------You have the following error-------------\n')
if __name__ == '__main__':
main()

DocuSign SMS Authentication

I am using DocuSign Soap API to send envelopes. It is working great. However SMS authentication is not working.
Phone Authentication is working as it should. I am using a demo DocuSign account, and in one of the threads I read that SMS needs to be enabled.
I checked DocuSign settings, but did not find any option under Admin >> Settings >> Authentication
pdfRecipient.RequireIDLookup = true;
//Phone Numbers
DocuSignAPI.ArrayOfString phoneNumbers = new DocuSignAPI.ArrayOfString();
phoneNumbers.SenderProvidedNumber = new List<String>{'4081231234'};
//Phone Authentication - WORKING
/* pdfRecipient.IDCheckConfigurationName = 'Phone Auth $';
DocuSignAPI.RecipientPhoneAuthentication phoneAuthentication = new DocuSignAPI.RecipientPhoneAuthentication();
phoneAuthentication.RecipMayProvideNumber = true;
phoneAuthentication.SenderProvidedNumbers = phoneNumbers;
pdfRecipient.PhoneAuthentication = phoneAuthentication; */
//SMS Authentication - NOT WORKING
pdfRecipient.IDCheckConfigurationName = 'SMS Auth $';
DocuSignAPI.RecipientSMSAuthentication smsAuthentication = new DocuSignAPI.RecipientSMSAuthentication();
smsAuthentication.SenderProvidedNumbers = phoneNumbers;
pdfRecipient.SMSAuthentication = smsAuthentication;
It should send the envelope but instead I'm getting this error message -
Web service callout failed:
WebService returned a SOAP Fault:
Recipient SMS authentication specified but information missing.
faultcode=soap:Client
faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx
I am passing accountId, recipientName, recipientId, recipientEmail as well.
I think your code is only adding the phone number to the first list but not the smsAuth list like this:
RecipientSMSAuthentication smsAuth = new RecipientSMSAuthentication();
smsAuth.SenderProvidedNumbers = new List<String>();
smsAuth.SenderProvidedNumbers.Add("4155551212");

Chatter Api Access to create Feed via Platform Trigger

I am trying to Create A chatter feed using Chatter API(As I need mention user in the post) from A platform event trigger.
But I am getting an error:- "Insufficient Privileges: The Connect API is not enabled for this user type." in Debug Logs
and the user that's shown on debug log is Automated Process and not the Authenticated user creating a post request.
So my question is Do I need to Authenticate to Chatter API inside the trigger? If yes How I can do that.
Or am I missing any chatter Configuration?
Trigger Code
trigger SampleEventsTrigger on Sample_Events__e (after insert) {
System.debug('Event Log');
for (Sample_Events__e event : Trigger.New) {
System.debug('Event: ' + event);
//postFeedForSmartwinnr.PostFeedMethod(event.CreatedById, event.userId__c, event.Notification_message__c); // Call function to Create Chatter
ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();
System.debug('feedItemInput: ' );
System.debug(feedItemInput);
messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
mentionSegmentInput.id = event.userId__c;
messageBodyInput.messageSegments.add(mentionSegmentInput);
textSegmentInput.text = event.Notification_message__c;
messageBodyInput.messageSegments.add(textSegmentInput);
System.debug(feedItemInput);
feedItemInput.body = messageBodyInput;
feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem;
//feedItemInput.subjectId = '0F9RR0000004CPw';
System.debug(feedItemInput);
ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement( Network.getNetworkId(), feedItemInput); // Error is on this line
System.debug('feedElement');
System.debug(feedElement);
}
}
Thanks in Advance...
As per my knowledge, the user present at that point is Automated Process who is able to post feed using class but, don't have access to chatter REST API

Resources